J
John
Hi, all-
I've got this working, but I'm wondering if there's a better way- kind of a
self-taught newb, not all that familiar with programming. Can I clean it up?
I've got a DataList nested within a Repeater - Repeater's source is
subcategories, the DataList display products within each subcategory.
Each product has a couple of fields I want displayed as checkboxes. I need
to set them checked or unchecked depending on a table field. This is the
code I've used, hooked to the DataLists's onItemDataBound event.
====
protected void checkCheck(object source,
System.Web.UI.WebControls.DataListItemEventArgs e)
{
CheckBox chkFeatured = (CheckBox)e.Item.FindControl("chkFeatured");
CheckBox chkStock = (CheckBox)e.Item.FindControl("chkStock");
chkFeatured.Checked =
bool.Parse(((SqlDataReader)((DataList)e.Item.NamingContainer).DataSource)["p
rodFeatured"].ToString());
chkStock.Checked =
bool.Parse(((SqlDataReader)((DataList)e.Item.NamingContainer).DataSource)["p
rodStock"].ToString());
}
====
Thanks in advance!
-John
I've got this working, but I'm wondering if there's a better way- kind of a
self-taught newb, not all that familiar with programming. Can I clean it up?
I've got a DataList nested within a Repeater - Repeater's source is
subcategories, the DataList display products within each subcategory.
Each product has a couple of fields I want displayed as checkboxes. I need
to set them checked or unchecked depending on a table field. This is the
code I've used, hooked to the DataLists's onItemDataBound event.
====
protected void checkCheck(object source,
System.Web.UI.WebControls.DataListItemEventArgs e)
{
CheckBox chkFeatured = (CheckBox)e.Item.FindControl("chkFeatured");
CheckBox chkStock = (CheckBox)e.Item.FindControl("chkStock");
chkFeatured.Checked =
bool.Parse(((SqlDataReader)((DataList)e.Item.NamingContainer).DataSource)["p
rodFeatured"].ToString());
chkStock.Checked =
bool.Parse(((SqlDataReader)((DataList)e.Item.NamingContainer).DataSource)["p
rodStock"].ToString());
}
====
Thanks in advance!
-John