brain has stalled datagrid checkboxlist

Discussion in 'ASP .Net Web Controls' started by cindy, Oct 18, 2005.

  1. cindy

    cindy Guest

    I am using asp template columns. I display box values from a lookup table.
    The datagrid displays field "bookid" and the checkbox displays "category"
    field for the book. The category field is a string concatenation of category
    values such as CT,MR,NM or just CT
    When the grid goes into edit mode I use the itemdatabound to determine
    whether to set checkbox as selected based on the value of the category field.
    ((CheckBoxList)e.Item.Cells[0].FindControl("cbl1")).SelectedValue =
    ds.Tables[0].Rows[cnt]["Category"].ToString();
    Ok if category = CT How do I get an array into the itemdatabound with comma
    delimiter so CT,MR for example will see values as CT and a MR:
    The update command for the grid builds the string by looping thru the
    selected values from the checkbox. Am I completely missing a better way?
    --
    cindy
     
    cindy, Oct 18, 2005
    #1
    1. Advertising

  2. string strCategory = "CT,MR";
    CheckBoxList cbl1= (CheckBoxList)e.Item.Cells[0].FindControl("cbl1");
    string[] aCategories= strCategory.Split (',');
    foreach (string str in aCategories)
    {
    System.Web.UI.WebControls.ListItem li= cbl1.Items.FindByValue (str);
    if (li != null) li.Selected =true ;
    }
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "cindy" wrote:

    > I am using asp template columns. I display box values from a lookup table.
    > The datagrid displays field "bookid" and the checkbox displays "category"
    > field for the book. The category field is a string concatenation of category
    > values such as CT,MR,NM or just CT
    > When the grid goes into edit mode I use the itemdatabound to determine
    > whether to set checkbox as selected based on the value of the category field.
    > ((CheckBoxList)e.Item.Cells[0].FindControl("cbl1")).SelectedValue =
    > ds.Tables[0].Rows[cnt]["Category"].ToString();
    > Ok if category = CT How do I get an array into the itemdatabound with comma
    > delimiter so CT,MR for example will see values as CT and a MR:
    > The update command for the grid builds the string by looping thru the
    > selected values from the checkbox. Am I completely missing a better way?
    > --
    > cindy
     
    Phillip Williams, Oct 18, 2005
    #2
    1. Advertising

  3. cindy

    cindy Guest

    Thank you very much, I had just stalled and you replied so quickly.
    --
    cindy


    "Phillip Williams" wrote:

    > string strCategory = "CT,MR";
    > CheckBoxList cbl1= (CheckBoxList)e.Item.Cells[0].FindControl("cbl1");
    > string[] aCategories= strCategory.Split (',');
    > foreach (string str in aCategories)
    > {
    > System.Web.UI.WebControls.ListItem li= cbl1.Items.FindByValue (str);
    > if (li != null) li.Selected =true ;
    > }
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "cindy" wrote:
    >
    > > I am using asp template columns. I display box values from a lookup table.
    > > The datagrid displays field "bookid" and the checkbox displays "category"
    > > field for the book. The category field is a string concatenation of category
    > > values such as CT,MR,NM or just CT
    > > When the grid goes into edit mode I use the itemdatabound to determine
    > > whether to set checkbox as selected based on the value of the category field.
    > > ((CheckBoxList)e.Item.Cells[0].FindControl("cbl1")).SelectedValue =
    > > ds.Tables[0].Rows[cnt]["Category"].ToString();
    > > Ok if category = CT How do I get an array into the itemdatabound with comma
    > > delimiter so CT,MR for example will see values as CT and a MR:
    > > The update command for the grid builds the string by looping thru the
    > > selected values from the checkbox. Am I completely missing a better way?
    > > --
    > > cindy
     
    cindy, Oct 18, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Nagle
    Replies:
    2
    Views:
    363
    Neil Hodgson
    Dec 12, 2007
  2. Steven D'Aprano

    Stalled ticket in Python bug tracker

    Steven D'Aprano, Jan 23, 2009, in forum: Python
    Replies:
    6
    Views:
    278
    Peter Otten
    Jan 24, 2009
  3. pataphor
    Replies:
    0
    Views:
    441
    pataphor
    Jun 14, 2009
  4. rnicz
    Replies:
    6
    Views:
    123
    rnicz
    Nov 19, 2004
  5. Replies:
    2
    Views:
    108
Loading...

Share This Page