RadioButtonList普通用法

来源:互联网 发布:剑三商城捏脸数据非法 编辑:程序博客网 时间:2024/04/28 03:18

RadioButtonList普通用法

在Aspx文件中:
<asp:RadioButtonList id="rblSex" runat="server" RepeatDirection="Horizontal" CssClass="RadioButtonList">
</asp:RadioButtonList>


在CS文件:
protected System.Web.UI.WebControls.RadioButtonList rblSex;

//绑定性别
this.rblSex.DataSource     = this.GetData(1,"staff","sex");//取得数据集
this.rblSex.DataValueField = "Value";
this.rblSex.DataTextField  = "Item";
this.rblSex.DataBind();

//读取姓别
for(int i=0;i<this.rblSex.Items.Count;i++)
{
 if(this.rblSex.Items[i].Value == DataTable.Row[i][0])
 {
  this.rblSex.SelectedItem.Selected = false;
  this.rblSex.Items[i].Selected = true;
 }
}

原创粉丝点击