如果还没有在转发器表中工作,当我选中复选框时它将转到else语句。有解决方案吗

时间:2014-08-06 13:18:16

标签: c# asp.net repeater

<asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>

  <asp:TextBox ID="txtAvailableID" runat="server"   text='<%#Eval("AvailableID") %>' ></asp:TextBox>    
 <asp:TextBox ID="txtSchedule" runat="server" text=' <%#Eval("ScheduleID") %>'></asp:TextBox>
            &nbsp;
            <%#Eval("Venue") %>
            &nbsp;
            <%#Eval("startTime").ToString() %>-<%#Eval("endtime") %><asp:CheckBox Checked="false" ID="cbschedule" runat="server" /><br /> 
            </ItemTemplate>
    </asp:Repeater>

在背后的代码中

protected void Button2_Click(object sender, EventArgs e)
        {
            int countchecked = 0;
            for (int item = 0; item < Repeater1.Items.Count; item++)
            {                  
                CheckBox box = Repeater1.Items[item].FindControl("cbschedule") as CheckBox;
                TextBox txtAvailableID = Repeater1.Items[item].FindControl("txtAvailableID") as TextBox;
                TextBox txtSchedule = Repeater1.Items[item].FindControl("txtSchedule") as TextBox;
                if (box.Checked)
                {
                    countchecked++;
                    TblEnrollDetail.Rows[item].Cells[0].Text = txtSchedule.Text.ToString();
                    TblEnrollDetail.Rows[item].Cells[1].Text = txtAvailableID.Text.ToString();

                }
                else
                {
                   String myStringVariable = "Do not choose more than 1";
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);





                }
            }

        }

0 个答案:

没有答案