600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 四大列表控件之RadioButtonList控件(单选按钮)

四大列表控件之RadioButtonList控件(单选按钮)

时间:2022-10-07 01:51:27

相关推荐

四大列表控件之RadioButtonList控件(单选按钮)

Default.aspx

<html xmlns="/1999/xhtml" ><head runat="server"><title>无标题页</title></head><body><form id="form1" runat="server"><div>请选择其中一项运动:<asp:RadioButtonList ID="RadioButtonList1" runat="server" Width="180px"></asp:RadioButtonList></div></form></body></html>

绑定数据到ListBox控件

public partial class _Default : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){if (!Page.IsPostBack){//数据生成DataSet ds = new DataSet();ds.Tables.Add("stu");ds.Tables["stu"].Columns.Add("stuNo", typeof(int));ds.Tables["stu"].Columns.Add("stuName", typeof(string));ds.Tables["stu"].Columns.Add("stuScore", typeof(int));ds.Tables["stu"].Rows.Add(new object[] { 1, "乒乓球", 100 });ds.Tables["stu"].Rows.Add(new object[] { 2, "篮球", 100 });ds.Tables["stu"].Rows.Add(new object[] { 3, "排球", 100 });ds.Tables["stu"].Rows.Add(new object[] { 4, "羽毛球", 100 });ds.Tables["stu"].Rows.Add(new object[] { 5, "足球", 100 });//绑定数据到ListBox控件this.RadioButtonList1.DataSource = ds.Tables["stu"];this.RadioButtonList1.DataValueField = "stuNo";this.RadioButtonList1.DataTextField = "stuName";this.RadioButtonList1.DataBind();}}}

结果:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。