从数据添加项,checkboxlist

页面

    <form id="form1" runat="server">
    <asp:CheckBoxList ID="CheckBoxList1" runat="server"
        oninit="CheckBoxList1_Init">

页面

    <form id="form1" runat="server">
    <asp:CheckBoxList ID="CheckBoxList1" runat="server"
        oninit="CheckBoxList1_Init">
    </asp:CheckBoxList>
    </form>

 

CS文件

   public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void CheckBoxList1_Init(object sender, EventArgs e)
        {
            string[] Genre = { "a1", "a2", "a3", "a4" };
            CheckBoxList1.DataSource = Genre;
            CheckBoxList1.DataBind();
        }
   
    }

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注