473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Urgent , please help-How to get child repeater checkbox status

Hello all,

I have a nested repeater, which displays categories(parent repeater) and
corresponding subcategories(child repeater). Both repeaters have checkboxes.
When I check category checkbox and subcategory check boxes and click on
submit button , I have to retrieve the corresponding categoryid and
subcategory id, so that I can store it to a table. I am getting the
categoryid but I am failing to get subcategoryid(actually I don't know how to
retrieve it).

Thanks
Ceema

My output will look like

(checkbox)Category1
(checkbox)SubCategory11.1
(checkbox)SubCategory11.2
(checkbox)SubCategory11.3
(checkbox)Category2
(checkbox)SubCategory12.1
(checkbox)SubCategory12.2
(checkbox)Category3
and my code for this is..
Code for repeater is
<asp:repeater id="parentRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
</HeaderTemplate>
<itemtemplate>
<tr>
<td>
<asp:CheckBox ID="chkIncld" Runat="server" Checked="true"
Enabled="true"></asp:CheckBox>
<asp:Label ID="lblCategoryID" Runat="server" text='<%# Container.dataitem
("CategoryID") %>' Visible="false">
</asp:Label>
</td>
</tr>
<br>
<asp:repeater id="childRepeater" runat="server" datasource='<%# Container.
DataItem.Row.GetChildRows("myrelation1") %>'>
<itemtemplate>
<tr>
<td>
<asp:CheckBox id='chksubid' SubId='<%# Container.dataitem("SD") %>'
Runat="server" Checked="true" />
<asp:Label ID="lblSubCategoryID" Runat="server" text='<%# Container.dataitem
("SD") %>' Visible="false">
</asp:Label>
<%# Container.DataItem("SubCategoryName") %>
</td>
</tr>
<br>
</itemtemplate>
</asp:repeater>
<FooterTemplate>
</table>
</FooterTemplate>
</itemtemplate>
</asp:repeater><asp:button id="Submit" onclick="Doit" runat="server"
Width="60px" Text="Submit" Height="20px"></asp:button><asp:label id="Label1"
runat="server" visible="false"></asp:label></form>

And code behind will look like

Public Sub Doit(ByVal Source As Object, ByVal E As EventArgs)
Response.Write("<br>")
Dim i As Integer

Dim iCount As Integer = parentRepeater.Items.Count - 1

Dim _chk As Integer

Dim _lblCateDesc As Label
Dim _lblDescID As Label

Dim _lblID As String
' Spin through all the items and add the checked Parts
For i = 0 To iCount

_chk = (CType(parentRepeater.Items.Item(i).FindControl("c hkIncld")
, CheckBox).Checked) * -1
_lblCateDesc = CType(parentRepeater.Items.Item(i).FindControl
("lblCategoryName"), Label)
_lblDescID = CType(parentRepeater.Items.Item(i).FindControl
("lblCategoryID"), Label)

If _chk = 1 Then

_lblID = _lblDescID.Text & " , " & _lblID

End If
Next
End sub
..
..
..
Nov 19 '05 #1
2 5494
You'll probably need a nested FOR EACH loop to go with the nested repeaters.
It's a pain (been there, done that) but it's fairly straightforward.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Ceema M via DotNetMonster.com" wrote:
Hello all,

I have a nested repeater, which displays categories(parent repeater) and
corresponding subcategories(child repeater). Both repeaters have checkboxes.
When I check category checkbox and subcategory check boxes and click on
submit button , I have to retrieve the corresponding categoryid and
subcategory id, so that I can store it to a table. I am getting the
categoryid but I am failing to get subcategoryid(actually I don't know how to
retrieve it).

Thanks
Ceema

My output will look like

(checkbox)Category1
(checkbox)SubCategory11.1
(checkbox)SubCategory11.2
(checkbox)SubCategory11.3
(checkbox)Category2
(checkbox)SubCategory12.1
(checkbox)SubCategory12.2
(checkbox)Category3
and my code for this is..
Code for repeater is
<asp:repeater id="parentRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
</HeaderTemplate>
<itemtemplate>
<tr>
<td>
<asp:CheckBox ID="chkIncld" Runat="server" Checked="true"
Enabled="true"></asp:CheckBox>
<asp:Label ID="lblCategoryID" Runat="server" text='<%# Container.dataitem
("CategoryID") %>' Visible="false">
</asp:Label>
</td>
</tr>
<br>
<asp:repeater id="childRepeater" runat="server" datasource='<%# Container.
DataItem.Row.GetChildRows("myrelation1") %>'>
<itemtemplate>
<tr>
<td>
<asp:CheckBox id='chksubid' SubId='<%# Container.dataitem("SD") %>'
Runat="server" Checked="true" />
<asp:Label ID="lblSubCategoryID" Runat="server" text='<%# Container.dataitem
("SD") %>' Visible="false">
</asp:Label>
<%# Container.DataItem("SubCategoryName") %>
</td>
</tr>
<br>
</itemtemplate>
</asp:repeater>
<FooterTemplate>
</table>
</FooterTemplate>
</itemtemplate>
</asp:repeater><asp:button id="Submit" onclick="Doit" runat="server"
Width="60px" Text="Submit" Height="20px"></asp:button><asp:label id="Label1"
runat="server" visible="false"></asp:label></form>

And code behind will look like

Public Sub Doit(ByVal Source As Object, ByVal E As EventArgs)
Response.Write("<br>")
Dim i As Integer

Dim iCount As Integer = parentRepeater.Items.Count - 1

Dim _chk As Integer

Dim _lblCateDesc As Label
Dim _lblDescID As Label

Dim _lblID As String
' Spin through all the items and add the checked Parts
For i = 0 To iCount

_chk = (CType(parentRepeater.Items.Item(i).FindControl("c hkIncld")
, CheckBox).Checked) * -1
_lblCateDesc = CType(parentRepeater.Items.Item(i).FindControl
("lblCategoryName"), Label)
_lblDescID = CType(parentRepeater.Items.Item(i).FindControl
("lblCategoryID"), Label)

If _chk = 1 Then

_lblID = _lblDescID.Text & " , " & _lblID

End If
Next
End sub
..
..
..

Nov 19 '05 #2
Ceema,

If you'd like, take a look at some datagrid code I have on my website,
www.aboutfortunate.com. If you click the "Code Library" link at the top of
the page and then use the search box you'll see to search for "Checkbox in
Datagrid" you'll get some sample code that is very similar to what you need
to do. In that code I loop through a datagrid's items to find which checkbox
is checked. Swap the grid for your repeater and it's very similar to what
you need.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ceema M via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
news:54***********@DotNetMonster.com...
Hello all,

I have a nested repeater, which displays categories(parent repeater) and
corresponding subcategories(child repeater). Both repeaters have
checkboxes.
When I check category checkbox and subcategory check boxes and click on
submit button , I have to retrieve the corresponding categoryid and
subcategory id, so that I can store it to a table. I am getting the
categoryid but I am failing to get subcategoryid(actually I don't know how
to
retrieve it).

Thanks
Ceema

My output will look like

(checkbox)Category1
(checkbox)SubCategory11.1
(checkbox)SubCategory11.2
(checkbox)SubCategory11.3
(checkbox)Category2
(checkbox)SubCategory12.1
(checkbox)SubCategory12.2
(checkbox)Category3
and my code for this is..
Code for repeater is
<asp:repeater id="parentRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
</HeaderTemplate>
<itemtemplate>
<tr>
<td>
<asp:CheckBox ID="chkIncld" Runat="server" Checked="true"
Enabled="true"></asp:CheckBox>
<asp:Label ID="lblCategoryID" Runat="server" text='<%# Container.dataitem
("CategoryID") %>' Visible="false">
</asp:Label>
</td>
</tr>
<br>
<asp:repeater id="childRepeater" runat="server" datasource='<%# Container.
DataItem.Row.GetChildRows("myrelation1") %>'>
<itemtemplate>
<tr>
<td>
<asp:CheckBox id='chksubid' SubId='<%# Container.dataitem("SD") %>'
Runat="server" Checked="true" />
<asp:Label ID="lblSubCategoryID" Runat="server" text='<%#
Container.dataitem
("SD") %>' Visible="false">
</asp:Label>
<%# Container.DataItem("SubCategoryName") %>
</td>
</tr>
<br>
</itemtemplate>
</asp:repeater>
<FooterTemplate>
</table>
</FooterTemplate>
</itemtemplate>
</asp:repeater><asp:button id="Submit" onclick="Doit" runat="server"
Width="60px" Text="Submit" Height="20px"></asp:button><asp:label
id="Label1"
runat="server" visible="false"></asp:label></form>

And code behind will look like

Public Sub Doit(ByVal Source As Object, ByVal E As EventArgs)
Response.Write("<br>")
Dim i As Integer

Dim iCount As Integer = parentRepeater.Items.Count - 1

Dim _chk As Integer

Dim _lblCateDesc As Label
Dim _lblDescID As Label

Dim _lblID As String
' Spin through all the items and add the checked Parts
For i = 0 To iCount

_chk =
(CType(parentRepeater.Items.Item(i).FindControl("c hkIncld")
, CheckBox).Checked) * -1
_lblCateDesc = CType(parentRepeater.Items.Item(i).FindControl
("lblCategoryName"), Label)
_lblDescID = CType(parentRepeater.Items.Item(i).FindControl
("lblCategoryID"), Label)

If _chk = 1 Then

_lblID = _lblDescID.Text & " , " & _lblID

End If
Next
End sub
.
.
.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Liu Ju | last post by:
Dear members: I want to use the multithread in my program which is developed in Visual C++ platform (version 6). I created a controlling function: UINT CCOMM1Dlg::WritingThreadFunc(LPVOID...
2
by: learner | last post by:
Hi, In a page, i have many links. I have some functions in a global file which is included in all linked pages. I want to have a reference to a window which is to be opened on clicking one link...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
8
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error for some of my web application users but not others??? Even though the application runs from a central webserver??? Thanks for...
1
by: MR | last post by:
Hi, it has been observed that when we try to instantiate a .Net dll for the first time in a session (e.g. from an exe in .Net), it takes almost 10 times compared to subsequent instantiations. ...
33
by: dembla | last post by:
Hey Frnds can anyone help me in this i need a program in 'c' PROGRAM to print NxN Matrix 9 1 8 1 2 3 2 7 3 as 4 5 6 6 4 5 7 8 9 in sorted form
1
by: alok sengar | last post by:
hi, I have already tried this URL's code "http://www.java2s.com/Code/CSharp/Network/SimpleSNMP.htm" but I am getting error when i am creating a UDP type Socket and recieving packet from this...
0
by: Christopher | last post by:
Urgent Help Needed: The EPVH-1.1 Visual Hull Library. Dear All, I am a student doing research in computer vision. The EPVH-1.1 Visual Hull Library will really help a lot in my research. I...
3
by: Mike | last post by:
Hi, I'm wondering if I can do this with ASP.NET?
1
by: psantosh12 | last post by:
Hello Frnds Please need help to resolve error.......... it is very very urgent........ The error is Runtime Error Description: An application error occurred on the server. The current custom...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.