erum mirza

erum mirza

  • NA
  • 432
  • 0

enable checkbox when another checkbox clicked in repeater

Dec 2 2010 7:43 AM

take a look here <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%"><%#Container.DataItem("packageid")%></td>
<td><asp:CheckBox ID="chk_packages" AutoPostBack=true runat="server" Text="Deluxe Platinum" /><%#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>

and code behind is
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)
        Dim cb As CheckBox = CType(sender, CheckBox)

        Dim i As Int32
        Dim cbid As CheckBox
        For i = 0 To Me.Repeater1.Items.Count - 1
            cbid = CType(Repeater1.Items(i).FindControl("single"), CheckBox)
            If Not (cbid Is Nothing) Then
                If cb.Checked = True Then
                    cbid.Enabled = True
                Else
                    cbid.Enabled = False
                    cbid.Checked = False

                End If
            End If
        Next
    End Sub

now the problem there are certain categories binded from database in repater like Deluxe PlatinumSuperior Deluxe Room or Deluxe PlatinumPremier Deluxe Room  and 2 more ,also two more columns bind single and double room the data in these columns are just rate .also i show checkboxes with these two cloumns
the problem if  i select category one say for example Deluxe PlatinumPremier Deluxe Room  only that checkboxes get enables (means single and double not all checkboxes )
hope i m quite clears ,please keep posting ur response ,if not clear yet !!
 
 

Answers (2)