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