G
Guest
Hi
There are a Checkboxlist with 20 checkboxitems and a string "1,3,5,7,9,11,13,15,17,20" which are those selectedindex of the checkboxlist. I used a foreach looping to record those selectedindex and I split the string and put them to a string array.
However, how can I assign those string array to SelectedIndex of Checkboxlist
[code
C#
protected System.Web.UI.WebControls.CheckBoxList c
string a = "1,3,5,7,9,11,13,15,17,20"
string[] b = a.Split(',')
for(int k=0; k < this.c.Items.Count; k++
if(this.c.Items[k].Value == b[k]
this.c.SelectedIndex = k
[/code
I used databind to bind a table to the checkboxlist
this.c.DataSource = ds.Tables[0].DefaultView
this.c.DataTextField = "checkboxitemname"
this.c.DataValueField = "id"
this.c.DataBind()
This code only shows the 20th selectedindex of the 20 checkboxlistitems. 1,3,5,7,9,11,13,15,17 were not selected
SelectedIndex does not has array. How can I fix this problem?
There are a Checkboxlist with 20 checkboxitems and a string "1,3,5,7,9,11,13,15,17,20" which are those selectedindex of the checkboxlist. I used a foreach looping to record those selectedindex and I split the string and put them to a string array.
However, how can I assign those string array to SelectedIndex of Checkboxlist
[code
C#
protected System.Web.UI.WebControls.CheckBoxList c
string a = "1,3,5,7,9,11,13,15,17,20"
string[] b = a.Split(',')
for(int k=0; k < this.c.Items.Count; k++
if(this.c.Items[k].Value == b[k]
this.c.SelectedIndex = k
[/code
I used databind to bind a table to the checkboxlist
this.c.DataSource = ds.Tables[0].DefaultView
this.c.DataTextField = "checkboxitemname"
this.c.DataValueField = "id"
this.c.DataBind()
This code only shows the 20th selectedindex of the 20 checkboxlistitems. 1,3,5,7,9,11,13,15,17 were not selected
SelectedIndex does not has array. How can I fix this problem?