'get how many packages have been selected Dim c As Int32 Dim str As String For Each dataItem As RepeaterItem In Repeater1.Items Dim ckchecked As CheckBox = DirectCast(dataItem.FindControl("chk_packages"), CheckBox) If ckchecked.Checked Then Dim chk_single As CheckBox = DirectCast(dataItem.FindControl("single_rate"), CheckBox) Dim chk_double As CheckBox = DirectCast(dataItem.FindControl("double_rate"), CheckBox) If chk_single.Checked Then c = c + 1 ElseIf chk_double.Checked Then c = c + 1 End If End If Next If c = 0 Then lbl_error_package.Visible = True lbl_error_package.Text = "please select at least one package" Else lbl_error_package.Visible = False End If
<asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> <table border="1" width="100%"> <tr> <th>id</th> <th align=left>Room Categories</th> <th>single</th> <th>Double</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td width="5%"> <asp:Label ID="Label3" runat="server" Text= '<%# Container.DataItem("packageid")%>' /></td> <td> <asp:CheckBox ID="chk_packages" AutoPostBack=true runat="server" Text = <%#Container.DataItem("package_name")%> /> </td> <td><%#Container.DataItem("single_rate")%><asp:CheckBox AutoPostBack=true ID="single" Enabled=false runat="server" />Number of Rooms<asp:TextBox ID="txt_single" Enabled=false width="10px" MaxLength="2" runat="server"></asp:TextBox></td> <td><%#Container.DataItem("double_rate")%><asp:CheckBox AutoPostBack=true ID="Double" Enabled=false runat="server" />Number of Rooms<asp:TextBox ID="txt_double" Enabled =false width="10px" MaxLength="2" runat="server"></asp:TextBox></td> <td></td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater>
its unable to find control and give exception Object reference not set to an instance of an object.
Dim chk_single As CheckBox = DirectCast(dataItem.FindControl("single_rate"), CheckBox)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)