根据输入类型更改数据表中的值=复选框选中没有runat属性的更改事件

时间:2016-02-01 10:51:14

标签: javascript c# jquery asp.net

这里我添加了一些带有动态ID的动态输入类型=“复选框”。我想更改数据表中的未选中值以检查是否选中了特定复选框。快速帮助。提前感谢

//Here is my aspx page code
     <form id="form1" runat="server">
        <div>
        <table border="1">
            <thead>

                <%string j = " Check"; %>
                <%for (int i = 0; i < 10;i++ )
                  {%>


                <th style="padding:2px; width:500px;">Table Head<br /><br />

                  <%
                      CheckBox chk = new CheckBox();
                      chk.ID = i + j;
                      chk.Text = "I am " + i + j; 
                       %> 
                <input type="checkbox" id="<%=i+j%>" value="<%=i+j %>" />
                    <label for="<%=i+j%>"><%=i+j %></label>



                </th>


                <%} %>

            </thead>
        </table>
            <asp:Button runat="server" Text="Click Me" OnClick="Unnamed_Click"/>
        </div>
        </form>
    //Here is my .cs page code
     protected void Page_Load(object sender, EventArgs e)
        {


                  dt_ViewAccessLog.Columns.Add("appId");
                  dt_ViewAccessLog.Columns.Add("Empcode");
                  dt_ViewAccessLog.Columns.Add("Status");
                  for (int i = 0; i < 10;i++ ) 
                  {

                      dt_ViewAccessLog.Rows.Add("App Id", i, "Unchecked");
                  }


        }
        protected void Unnamed_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dt_ViewAccessLog.Rows.Count; i++)
            {
                Response.Write(dt_ViewAccessLog.Rows[i][0].ToString() +"            "+ dt_ViewAccessLog.Rows[i][1].ToString() +"             "+ dt_ViewAccessLog.Rows[i][2].ToString()+"----");
            }
            HtmlInputCheckBox cb = (HtmlInputCheckBox)form1.FindControl("0 Check");
            if (cb != null && cb.Checked)
            {
                Response.Write("Done...");
            }
        }

0 个答案:

没有答案