1.DropDrunList
前台写入:
<asp:DropDownList runat="server" ID="DDlist_SJ"></asp:DropDownList>
后台写入:
DataTable dt = new DataTable();
this.DDlist_SJ.DataSource = dt;
this.DListType.DataTextField = "TYPE_NAME";
this.DListType.DataValueField = "TYPE_ID"; this.DDlist_SJ.DataBind();
添加空行:
this.DDlist_SJ.Items.Add(new ListItem("---请选择-----"));
赋值或获取text的值为:
string i=this.DListType.SelectedItem.text.ToString();
赋值或获取value的值为:
string i=this.DListType.Selectedvalue.ToString();
2.CheckBox
前台写入: <asp:CheckBox ID="cboXSBJ" Checked="true" runat="server" Text="显示标记" />
后台获取:
获取单选框的值:
string i = (this.cboXSBJ.Checked == true ? "1" : "0");
设置单选框的值。
this.cboXSBJ.Checked = (dt.Rows[0]["XSBJNAME"].ToString() == "1" ? true : false);