Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
<asp:PlaceHolder   ID="PlaceHolder3" runat="server"  Visible=false > <Strong>Hotel Requirement</Strong>
             <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" /></td>

<td><%#Container.DataItem("double_rate")%><asp:CheckBox  AutoPostBack=true ID="Double" runat="server" /></td>
<td><asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
             </asp:Repeater>
        </asp:PlaceHolder>



I want so that when any package checkbox is clicked in repeater, two other checkboxes in repeater (single,double get enable) in the same row and enabled.
When I un-uncheck it, they are also disabled.

I write some stuff in my application in order to do but it's not working as required.

See the code

VB
Private Sub Repeater1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemCreated
        Dim ri As RepeaterItem = CType(e.Item, RepeaterItem)
        Dim elemType As ListItemType = e.Item.ItemType
        If (elemType = ListItemType.Item) OrElse (elemType = ListItemType.AlternatingItem) Then
          Dim cb As CheckBox = ri.FindControl("chk_packages")
            AddHandler cb.CheckedChanged, AddressOf Me.myCheckedChanged
           'cb.CheckedChanged += New EventHandler(CheckedChanged)
        End If
    End Sub
Private Sub myCheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
/// I need help here
end sub
Posted
Updated 2-Dec-10 21:50pm
v3
Comments
Sunasara Imdadhusen 3-Dec-10 2:21am    
Hi you can done using Javascript, can i send you a code for the same?
Dalek Dave 3-Dec-10 3:50am    
Edited for Grammar and Readability.

problem has been resolved , i already did it
 
Share this answer
 
Comments
Dalek Dave 3-Dec-10 3:50am    
Well Done, always feels good when you solve something!
peakercai 31-May-11 15:19pm    
Would you please tell me how you solve it, I have same problem now! thanks!
ok now that problem has been "reslolved" now i need to put certain validation in that means at least one Packages must be selected with either single or double rooms

so behind submitt button i write follwoing code

VB
'get how many packages hav 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


and .aspx page is
XML
<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.

VB
Dim chk_single As CheckBox = DirectCast(dataItem.FindControl("single_rate"), CheckBox)


i need to check if user select package he must select either single or double room package

i hope i m quite clear in problem
 
Share this answer
 
Comments
Sandeep Mewara 3-Dec-10 12:22pm    
Don't post another question as an answer. Post as a new question.

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