Specified Cast is Invalid – Telerik RadGrid asp:CheckBox

30
Jun
0

Great solution to the “specified cast is invalid” problem while binding an asp.net CheckBox control inside of an Telerik RadGrid FormTemplate.

ASP.NET Classic Controls – Grid Forum – asp:Checkbox in FormTemplate. “Specified Cast is Invalid” .

From Fabian Schulz:

I ran across the same problem and have created a simple solution, which is most easy to use:

Create a usercontrol with the following code:

myCheckbox.ascx:

myCheckbox.ascx.cs:
public partial class Controls_myCheckBox : System.Web.UI.UserControl
{

private bool m_checked = false;

public object Checked
{
get { return m_checked; }
set
{
if (value.GetType() == DBNull.Value.GetType())
m_checked = false;
else if (value == null)
m_checked = false;
else if (value.GetType() == typeof(bool))
m_checked = (bool)value;
else
m_checked = false;
}
}

protected void Page_Load(object sender, EventArgs e)
{
m_checked = CheckBox1.Checked;
}

protected void Page_PreRender()
{
CheckBox1.Checked = m_checked;
}
}

In your aspx page you need to register that control in the head:

And now – you can use it like a regular checkbox without the Null problem:

Hope this helps!

Fabian

Go Ask Your Father

16
Jun
0

Act One, episode 289 of This American Life is really good when Lenny finds out the results of his paternity test. He opens the letter and reads the results while the tape is recording the episode. Good stuff. Have a listen.

Episode 289

Filed under: misc

Find locked files in Mac OS X (via Terminal)

8
Jun
0

Open Terminal.

type: find /Users/youraccountname/ -flags uchg

This will search your home directory for any file that is locked (user locked, or ‘immutable’ flag).

Got this great info from the manual pages of ‘find’ and ‘chflags’.
man find
man chflags

Happy hunting for those “locked” files!

“This American Life” that made me think

3
Jun
0

I subscribe to the podcast “This American Life.” Usually I just listen while I’m working in the morning over a cup of coffee. Its a good break from NPR.

Episode 223: Classifieds, grabbed my attention as it is talking about newspaper classifieds which my company creates software for both print and online publications.

Its a good listen, here.