Friday, March 31, 2006
Setting DataView checkbox for custom entity
It's a pain formatting code for blogs. Save the hassles and go here.
Now, ever wanted to set a checkbox in asp.net 2.0 after you have databound to it with a custom object? This code may be useful and save you some time :
read 0 comments |
Now, ever wanted to set a checkbox in asp.net 2.0 after you have databound to it with a custom object? This code may be useful and save you some time :
protected void ucDetailsView1_DataBound(object sender, EventArgs e)
{
DetailsView dv = sender as DetailsView;
if (dv == null)
return;
IAccount account = dv.DataItem as IAccount;
if (account != null)
{
CheckBox cb = dv.FindControl("ucMyCheckbox") as CheckBox;
if (cb != null)
cb.Checked = account.IsEnabled;
}
}
read 0 comments |