Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI guys,

I'm using bootstrap theme n master page in asp.net project.

n i dont have any UpdatePanel also.

Just, i have checkbox n some other controls in a repeater, in asp.net page.

But in the code behind,

the checkbox checked value getting false, instead of true.

XML
<asp:Repeater ID="Repeater1" runat="server" EnableTheming="True">
            <HeaderTemplate>
                <table class="table table-bordered table-hover">
                    <thead class="bg-light-blue">
                        <tr>
                            <th>
                                S.No.
                            </th>
                            <th>
                                Select
                            </th>
                            <th>
                                Main Chemicals
                            </th>
                            <th>
                                15%
                            </th>
                            <th>
                                20%
                            </th>
                            <th>
                                No.of Rows
                            </th>
                            <th>
                                Volume
                            </th>
                        </tr>
                    </thead>
                    <tbody>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td valign="middle" align="center" style="width: 50px" class="bg-gray">
                        <b style="color: Black">
                            <%# Container.ItemIndex + 1 %>
                        </b>
                    </td>
                    <td align="center" style="width: 50px">
                        <asp:CheckBox ID="chkSelect" runat="server" />
                    </td>
                    <td>
                        <asp:Label ID="lblchm" CssClass="textBlack" Font-Bold="true" runat="server" Text='<%# Eval("CName") %>'></asp:Label>
                        <asp:HiddenField ID="hdnChemical" runat="server" Value='<%# Eval("RecID") %>' />
                    </td>
                    <td align="center" style="width: 50px">
                        <asp:RadioButton ID="rb15" GroupName="percentage" runat="server" />
                    </td>
                    <td align="center" style="width: 50px">
                        <asp:RadioButton ID="rb20" GroupName="percentage" runat="server" />
                    </td>
                    <td>
                        <asp:TextBox ID="txtrows" runat="server" CssClass="form-control" AutoPostBack="False"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtrows"
                            SetFocusOnError="true" ForeColor="Red" ErrorMessage="Please Enter Only Numeric"
                            Style="z-index: 101; left: 424px; position: absolute; top: 285px" ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
                    </td>
                    <td>
                        <asp:TextBox ID="txtvolume" runat="server" CssClass="form-control" AutoPostBack="False"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtvolume"
                            SetFocusOnError="true" ForeColor="Red" ErrorMessage="Please Enter Only Numeric"
                            Style="z-index: 101; left: 424px; position: absolute; top: 285px" ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </tbody> </table>
            </FooterTemplate>
        </asp:Repeater>
<br />

<table width="100%">
    <tr>
        <td align="center">
            <asp:Button ID="btncncl" runat="server" Text="Cancel" CssClass="btn btn-sm btn-danger"
                Font-Bold="True" OnClick="btncncl_Click" />&nbsp
            <asp:Button ID="btnok" runat="server" Text="Next >>" CssClass="btn btn-sm btn-primary"
                Font-Bold="True" OnClick="btnnext_Click" />
        </td>
    </tr>
</table>



pageload:

C#
if (!IsPostBack)
            {
                

                    int recid = Convert.ToInt32(Request.QueryString["RECID"]);
                    getProjectDetails(recid);
                    Fill_Repeater();

                }


Insertion Code:
protected void btnnext_Click(object sender, EventArgs e)
       {
           int i = 0;
           int PrjID = Convert.ToInt32(Request.QueryString["RECID"]);
           foreach (RepeaterItem item in Repeater1.Items)
           {
               //TextBox t = (TextBox)item.FindControl("txtrows");
               CheckBox chk = (CheckBox)item.FindControl("chkSelect");

                   if (chk.Checked)//getting false
                   {
                       RadioButton rb1 = (RadioButton)item.FindControl("rb15");
                       RadioButton rb2 = (RadioButton)item.FindControl("rb20");

                       bool fifteen = rb1.Checked;
                       bool twenty = rb2.Checked;

                       HiddenField hdn = (HiddenField)item.FindControl("hdnChemical");
                       int ChemicalID = Convert.ToInt32(hdn.Value);

                       TextBox rows = (TextBox)item.FindControl("txtrows");
                       string sRows = rows.Text;
                       TextBox vol = (TextBox)item.FindControl("txtvolume");
                       string svol = vol.Text;

                       //Insert query here!
                       string data = PrjID + "," + fifteen + "," + twenty + "," + sRows + "," + svol + "," + Session["UserRecID"].ToString() + "," + ChemicalID.ToString();
                       i = bl.InsertAssignChemicals(data);

                   }

           }

           if (i > 0)
           {
               bl.UpdateProjectStatus(PrjID, 2);
               Response.Redirect("ProjectList.aspx");
           }

       }


can anyone... plzzz help me.

thnx
Posted
Updated 20-May-14 4:32am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900