CheckBoxList取值
string strrighgs = "" ;
for ( int i = 0 ; i < this .cblrighgs.Items.Count; i ++ )
{
if (this.cblrighgs.Items[i].Selected == true)
{
strrighgs += this.cblrighgs.Items[i].Value+"|";
}
}
string str = "" ;
foreach (ListItem li in cblrighgs.Items)
{
if (li.Selected == true)
{
str += li.Value+";";
}
}
Response.Write(str);
Response.End();
CheckBoxList取值及勾选
string [] strtemp = strapp.Split( '| ' );
foreach ( string str in strtemp)
{
for (int i = 0; i < cblrighgs.Items.Count; i++)
{
if (this.cblrighgs.Items[i].Value == str)
{
this.cblrighgs.Items[i].Selected = true;
}
}
}
string strrighgs = "" ;
for ( int i = 0 ; i < this .cblrighgs.Items.Count; i ++ )
{
if (this.cblrighgs.Items[i].Selected == true)
{
strrighgs += this.cblrighgs.Items[i].Value+"|";
}
}
string str = "" ;
foreach (ListItem li in cblrighgs.Items)
{
if (li.Selected == true)
{
str += li.Value+";";
}
}
Response.Write(str);
Response.End();
CheckBoxList取值及勾选
string [] strtemp = strapp.Split( '| ' );
foreach ( string str in strtemp)
{
for (int i = 0; i < cblrighgs.Items.Count; i++)
{
if (this.cblrighgs.Items[i].Value == str)
{
this.cblrighgs.Items[i].Selected = true;
}
}
}
转载于:https://blog.51cto.com/45518862/59131