Code this more easily?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Code this more easily?

    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(obje ct source,
    System.Web.UI.W ebControls.Data ListItemEventAr gs e)
    {

    CheckBox chkFeatured = (CheckBox)e.Ite m.FindControl(" chkFeatured");
    CheckBox chkStock = (CheckBox)e.Ite m.FindControl(" chkStock");

    chkFeatured.Che cked =
    bool.Parse(((Sq lDataReader)((D ataList)e.Item. NamingContainer ).DataSource)["p
    rodFeatured"].ToString());

    chkStock.Checke d =
    bool.Parse(((Sq lDataReader)((D ataList)e.Item. NamingContainer ).DataSource)["p
    rodStock"].ToString());

    }

    ====

    Thanks in advance!

    -John


Working...