About the author

Imran Imran
Like Development in DotNet.

E-mail me Send mail
Search Entire Web

Recent Articles

 
1: Master Pages
Category: ASP.Net
Added: 1/31/2008

 
2: Caching with ASP.NET
Category: ASP.Net
Added: 1/31/2008

 
3: Free Microsoft Press E-Book Offer!
Category: ASP.Net
Added: 1/30/2008

 
4: Timer Control in Asp.Net
Category: ASP.Net
Added: 1/29/2008

 
5: Checkbox selection with ajax
Category: ASP.Net
Added: 1/29/2008

 
6: UrlRewriter with asp.net
Category: ASP.Net
Added: 1/19/2008

 
7: Auto complete textbox with Ajax
Category: ASP.Net
Added: 1/15/2008

 
8: Upload file with Asp.Net
Category: ASP.Net
Added: 1/15/2008

 
9: User Rating Technique
Category: ASP.Net
Added: 1/8/2008

 
10: Encryption And Decryption Library
Category: ASP.Net
Added: 1/5/2008

Checkbox selection with ajax

by Imran 29/January/2008

i Used ajax for selection of parent child checkbox.

<asp:ScriptManager ID="scriptManager" runat="server" />

<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">

<contenttemplate>

<asp:DataList ID="DataList1" runat="server"

Width="100%" ItemStyle-VerticalAlign="Top" RepeatDirection="Horizontal" RepeatColumns="4">

<ItemTemplate>

<table cellpadding="0" cellspacing="0" border="0">

<tr>

<td colspan="2">

<asp:CheckBox runat="server" AutoPostBack="true" Font-Bold="true" ID="chkMainCat"

Text='<%#DataBinder.Eval(Container.DataItem, "CName")%>' OnCheckedChanged="HandleChk" />

</td>

</tr>

<tr>

<td style="width:2pt">

&nbsp;

</td>

<td>

<asp:CheckBoxList Font-Size="7pt" runat="server" ID="chkSubCat">

</asp:CheckBoxList>

</td>

</tr>

</table>

</ItemTemplate>

</asp:DataList>

</ContentTemplate>

</asp:UpdatePanel>

Protected Sub HandleChk(ByVal sender As Object, ByVal e As EventArgs)

Dim chkMainCat As CheckBox = TryCast(sender, CheckBox)

Dim row As DataListItem = DirectCast(chkMainCat.NamingContainer, DataListItem) Dim GridView1 As GridView = FindControl("GridView1")

Dim I As Integer

For I = 0 To DataList1.Items.Count - 1

If I = Val(row.ItemIndex) Then

Dim chkMCat As CheckBox = DataList1.Items(I).FindControl("chkMainCat") Dim chkSubCat As CheckBoxList = DataList1.Items(I).FindControl("chkSubCat")

Dim J As Integer

For J = 0 To chkSubCat.Items.Count - 1

If chkMCat.Checked = True Then

chkSubCat.Items(J).Selected = True

Else

chkSubCat.Items(J).Selected = False

End If

Next

End If

Next

End Sub





Powered by DotNetClassic.com