473,387 Members | 1,542 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.

Checkbox and repeater

I have datarepeater with checkBox:
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem,"adv_name") %></td>
<td><%# DataBinder.Eval(Container.DataItem,"adv_start") %></td>
<td><%# DataBinder.Eval(Container.DataItem,"adv_end") %></td>
<td align="center">
<asp:CheckBox Runat="server" ID='chkPList'></asp:CheckBox>
</td>
</tr>
</ItemTemplate>

I would like to set the ID of checkBox dynamic:

Private Sub rprPlists_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
rprPlists.ItemDataBound

If (e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType =
ListItemType.Item) Then

Dim chkBox As CheckBox
chkBox = e.Item.FindControl("chkPList")
chkBox.ID = e.Item.DataItem(0).ToString() 'for example: "111"

End If

End Sub

It works, now I have checkBox with desired ID.

When user click the submit, I would like to check, which checkBoxes are
clicked and then read it's ID.

Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOk.Click

Dim i As Integer
Dim chkBox As CheckBox
Dim ID as string

For i = 0 To rprPlists.Items.Count - 1
chkBox = CType(rprPlists.Items(i).FindControl("chkPlist"), CheckBox)
if chkBox.checked=true then
id=chkBox.ID
end if
Next

End Sub

This works, I get the checkBox

When I read it's ID, I get the value: "chkPList" instead of desired ID
("111"), which was set on ItemDataBound.
Why? How can I read the right ID?

Thank you,
Simon
Nov 18 '05 #1
0 1076

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

Similar topics

2
by: Thomas R | last post by:
Is is possible? In VS.NET 2003, Binding data to the repeater is easy, but when I try to add an ASP:checkbox to the .aspx page, the designer won't recognize it, hence the code view doesn't allow...
2
by: Alan Silver | last post by:
Hello, I have a repeater with a list of products in it. Each item in the repeater has a checkbox, allowing the product to be selected. When a link button is clicked, I want to loop through the...
2
by: Andrew | last post by:
Hi, I have a problem capturing the checkboxes that are checked, I get false irrespective of wether they are checked or not. I have gone thru the sample code on this forum, but they dun seem to...
2
by: Ceema M via DotNetMonster.com | last post by:
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...
0
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.