添加:
1、DropDownList:string national = ddlNational.SelectedValue.ToString();
2、RadioButtonList:int sex = Convert.ToInt32(this.rdoltSex.Text.ToString());
3、CheckBoxList:
string strHobby = "";
for (int i = 0; i < this.chklsHobby.Items.Count; i++)
{
if (this.chklsHobby.Items[i].Selected == true)
{
strHobby += this.chklsHobby.Items[i].Value + "|";
}
}
string hobby = strHobby;
显示:
1、DropDownList:ddlNational.SelectedValue = dr["cNational"].ToString();
2、RadioButtonList:
string selSex = dr["sex"].ToString();
rdoltSex.SelectedIndex = rdoltSex.Items.IndexOf(rdoltSex.Items.FindByValue(selSex));
3、CheckBoxList:
string strapp = dr["hobby"].ToString();
string[] strtemp = strapp.Split('|');
foreach (string str in strtemp)
{
for (int i = 0; i < chklsHobby.Items.Count; i++)
{
if (this.chklsHobby.Items[i].Value == str)
{
this.chklsHobby.Items[i].Selected = true;
}
}
}
转载于:https://www.cnblogs.com/tiantangwater/archive/2008/12/24/1361572.html