设定下拉列表控件DropDownList,复选按钮CheckBox,RadioButton默认值总结测试
2009-03-14 00:16
567 查看
设定下拉列表控件DropDownList,复选按钮CheckBox,RadioButton默认值总结测试
//设定下拉列表控件DropDownList默认值
//方式一
//this.dropClassName.Items.FindByValue(ClassName).Selected = true;
//方式二
//this.dropClassName.Items.Add(ClassName);
//this.dropClassName.Items[this.dropClassName.Items.Count - 1].Value = ClassName;
//this.dropClassName.SelectedIndex = this.dropClassName.Items.Count - 1;
//方式三
//ListItem item = new ListItem(ClassName, ClassName);
//this.dropClassName.Items.Insert(0, item);
//方式四
this.dropClassName.SelectedValue = ClassName;
//设定复选按钮CheckBox控件默认值
string IsEssence = myDataSet.Tables[0].Rows[0]["IsEssence"].ToString();
if (IsEssence == "True")
{
this.chkIsEssence.Checked = true;//SQL Server数据库中存储的值为"1",取真
}
else
{
this.chkIsEssence.Checked = false;//SQL Server数据库中存储的值为"0",取假
}
//设定单选按钮控件默认值
string IsHot = myDataSet.Tables[0].Rows[0]["IsHot"].ToString();
if (IsHot == "True")
{
this.rdoIsHot.Checked = true;//SQL Server数据库中存储的值为"1",取真
}
else
{
this.rdoIsHot.Checked = false;//SQL Server数据库中存储的值为"0",取假
}
//设定下拉列表控件DropDownList默认值
//方式一
//this.dropClassName.Items.FindByValue(ClassName).Selected = true;
//方式二
//this.dropClassName.Items.Add(ClassName);
//this.dropClassName.Items[this.dropClassName.Items.Count - 1].Value = ClassName;
//this.dropClassName.SelectedIndex = this.dropClassName.Items.Count - 1;
//方式三
//ListItem item = new ListItem(ClassName, ClassName);
//this.dropClassName.Items.Insert(0, item);
//方式四
this.dropClassName.SelectedValue = ClassName;
//设定复选按钮CheckBox控件默认值
string IsEssence = myDataSet.Tables[0].Rows[0]["IsEssence"].ToString();
if (IsEssence == "True")
{
this.chkIsEssence.Checked = true;//SQL Server数据库中存储的值为"1",取真
}
else
{
this.chkIsEssence.Checked = false;//SQL Server数据库中存储的值为"0",取假
}
//设定单选按钮控件默认值
string IsHot = myDataSet.Tables[0].Rows[0]["IsHot"].ToString();
if (IsHot == "True")
{
this.rdoIsHot.Checked = true;//SQL Server数据库中存储的值为"1",取真
}
else
{
this.rdoIsHot.Checked = false;//SQL Server数据库中存储的值为"0",取假
}
相关文章推荐
- 设定下拉列表控件DropDownList,复选按钮CheckBox,RadioButton默认值总结测试
- 设定下拉列表控件DropDownList,复选按钮CheckBox,RadioButton默认值总结测试
- CheckBox(复选按钮)/RadioButton(单选按钮)/BulletedList控件
- UI控件之RadioButton(单选按钮)&Checkbox(复选按钮)
- 下拉列表(Spinner),多选框(CheckBox),单选按钮(RadioButton)的使用
- C# GridView 控件绑定下拉列表框及给下拉列表框设定默认值
- ASP.NET自定义Web服务器控件-DropDownList/Select下拉列表控件
- (总结)Swing组件的使用---按钮(JButton),组合框(JComboBox),下拉列表(JList)和颜色选择器(JColorChooser)
- Android 控件之 Spinner下拉列表 使用简单总结
- 下拉列表等控件默认值的设置
- vs2005/.net2.0 控件实例之 下拉列表《DropDownList》
- DropdownList下拉列表控件的使用
- 下拉列表、单选按钮、复选框常用用法总结
- Android控件Spinner实现下拉列表测试代码
- [置顶] Android--(11)--解读单选(RadioButton)和复选(CheckBox)按钮
- javascript获取单选按钮,复选按钮,下拉列表的值
- Vue.js---表单标签中的单选按钮、复选按钮和下拉列表的取值问题
- 实例4-5 实现联动打的下拉列表DropDownList控件
- select下拉列表 和 radio单选按钮控件开关---- 根据值选择选项 & change事件
- ASP.NET中 RadioButtonList(单选按钮组),CheckBoxList(复选框组),DropDownList(下拉框),ListBox(列表框),BulletedList(无序列表)的使用前台绑定