Code this more easily?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top