473,511 Members | 11,345 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repeater control checkbox checked event

using VB.net (2005) ASP.net 2.0

I have a repeater control with the item template, in the item template
I have two checkboxes

How to capture event When user checks the checkboxes? What event
fires on the repeater

Repeater Control Item Template

TextBox
Checkbox1 v
Checkbox2
Label Control

When user checks either of the checkboxes I want to update the label
with new value...

Jun 6 '07 #1
5 24513
On Jun 6, 9:39 pm, c_shah <shah.chi...@netzero.netwrote:
using VB.net (2005) ASP.net 2.0

I have a repeater control with the item template, in the item template
I have two checkboxes

How to capture event When user checks the checkboxes? What event
fires on the repeater

Repeater Control Item Template

TextBox
Checkbox1 v
Checkbox2
Label Control

When user checks either of the checkboxes I want to update the label
with new value...
You need to add an EventHandler in the ItemCreated event of the
repeater

private void Repeater1_ItemCreated(object sender,
RepeaterItemEventArgs e)
{
RepeaterItem ri=(RepeaterItem)e.Item;

if (ri.ItemType==ListItemType.Item ||
ri.ItemType==ListItemType.AlternatingItem)
{
CheckBox cb=ri.FindControl("Checkbox1") as CheckBox;
cb.CheckedChanged +=new EventHandler(CheckedChanged);
}
}

private void CheckedChanged(object sender, EventArgs e)
{
CheckBox cb=(CheckBox)sender;
if (cb.Checked)
....
}

Jun 6 '07 #2
On Jun 6, 10:52 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Jun 6, 9:39 pm, c_shah <shah.chi...@netzero.netwrote:
Sorry, forgot that you have asked for VB

Private Sub Repeater1_ItemCreated(ByVal sender As Object, ByVal e As
RepeaterItemEventArgs)
Dim ri As RepeaterItem = CType(e.Item, RepeaterItem)
If ri.ItemType = ListItemType.Item Or ri.ItemType =
ListItemType.AlternatingItem Then
Dim cb As CheckBox = CType(ri.FindControl("Checkbox1"), CheckBox)
AddHandler cb.CheckedChanged, AddressOf Me.CheckedChanged
End If
End Sub

Private Sub CheckedChanged(ByVal sender As Object, ByVal e As
EventArgs)
Dim cb As CheckBox = CType(sender, CheckBox)
If cb.Checked Then
Label1.Text = "Checked"
else
Label1.Text = ""
End If
End Sub

Jun 6 '07 #3
Alexy, thank you.

I have another question. I would appreciate if you can answer my
question.

ItemTemplate of a repeater has two checkboxes and a label. (each
checbox is an option) and label control will display price. if one or
both the checkboxes is checked price need to be updated on the lable.
solution you proviced will not as I bound repeater with a datasset
(few rows) So for each row in my dataset i have have two checkboxes
and a label.

each row will have checkboxes and price label

i only want to update label (for which checkbox is checked)..

I guess I have to iterate through the number of items bound to
repeater and find out which row is checked and update label for that
item

any code help

Jun 7 '07 #4
On Jun 7, 6:14 pm, c_shah <shah.chi...@netzero.netwrote:
Alexy, thank you.

I have another question. I would appreciate if you can answer my
question.

ItemTemplate of a repeater has two checkboxes and a label. (each
checbox is an option) and label control will display price. if one or
both the checkboxes is checked price need to be updated on the lable.
solution you proviced will not as I bound repeater with a datasset
(few rows) So for each row in my dataset i have have two checkboxes
and a label.

each row will have checkboxes and price label

i only want to update label (for which checkbox is checked)..

I guess I have to iterate through the number of items bound to
repeater and find out which row is checked and update label for that
item

any code help
What's the purpose of that repeater? Using the CheckedChanged event
you will postback the page each time. If you don't update the
datasource the postback makes no sense for me. If the label depends on
checkboxes only, you can change its text using a client js. Otherwise
you have to iterate through the items, I think

Jun 7 '07 #5
On Jun 7, 11:37 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Jun 7, 6:14 pm, c_shah <shah.chi...@netzero.netwrote:


Alexy, thank you.
I have another question. I would appreciate if you can answer my
question.
ItemTemplate of a repeater has two checkboxes and a label. (each
checbox is an option) and label control will display price. if one or
both the checkboxes is checked price need to be updated on the lable.
solution you proviced will not as I bound repeater with a datasset
(few rows) So for each row in my dataset i have have two checkboxes
and a label.
each row will have checkboxes and price label
i only want to update label (for which checkbox is checked)..
I guess I have to iterate through the number of items bound to
repeater and find out which row is checked and update label for that
item
any code help

What's the purpose of that repeater? Using the CheckedChanged event
you will postback the page each time. If you don't update the
datasource the postback makes no sense for me. If the label depends on
checkboxes only, you can change its text using a client js. Otherwise
you have to iterate through the items, I think- Hide quoted text -

- Show quoted text -
You could also put a field somewhere in the repeater that you could
use to fund your items unique ID, to go perform another function on
that item.
to keep it simple, say one of the labels is a record id.

an example is what I use for data grids:
CheckBox myCheckBox = (CheckBox)sender;
GridViewRow dgi;

dgi = (GridViewRow)myCheckBox.Parent.Parent;
string sInvoiceItemID = dgi.Cells[1].Text.Trim();
Trace.Write(sInvoiceItemID);

theMethodTodoRealWork( sInvoiceItemID);

you have identified the item they checked, now perform the operation
on it

a full article that showed me this: http://aspnet.4guysfromrolla.com/articles/052406-1.aspx
there is also some stuff over at codeproject.com. Do a search for
checkboxes

If you already figured it out, then this is just long term storage for
me and the next time I forget how to do this :).
Jun 15 '07 #6

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

Similar topics

2
11761
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
5023
by: Mark | last post by:
I am attempting to build a repeating list using a repeater control. I want to add a checkbox to each item (line) and 'Select All' and 'Clear All' buttons. I have figured out how to do this...
1
1393
by: Z D | last post by:
Hello, I have a checkbox control as one of the items within my repeater control. I've set the AutoPostBack=True on the checkbox. How do I access the event (so that I can run some code)...
4
2693
by: Imran Aziz | last post by:
Hello All, I display a list of entries with a checkbox against them using a repeater control bound to a database table. Based on the value of database table I want to either show the checkbox for...
2
6391
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...
4
7399
by: sck10 | last post by:
Hello, I have a repeater that is bound to a SQL Server table. I would like to place a summary in the footer for the item count and product cost. I have two fields. One for the product name...
0
2253
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...
1
1834
by: Doogie | last post by:
Hi, I have been trying to get a checkbox added to a repeater control of mine and then try to access events of the repeater control when a user clicks the checkbox. At first, since the control is...
3
2893
by: Mahathi | last post by:
Hi I have a small problem in maintaining the state of a check box. Please do me a favour by telling me the procedure how to do that. My requirement is that "I have to map some roles with...
0
7251
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
7148
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
7367
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
7430
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...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
451
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.