473,770 Members | 2,069 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 24527
On Jun 6, 9:39 pm, c_shah <shah.chi...@ne tzero.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_ItemC reated(object sender,
RepeaterItemEve ntArgs e)
{
RepeaterItem ri=(RepeaterIte m)e.Item;

if (ri.ItemType==L istItemType.Ite m ||
ri.ItemType==Li stItemType.Alte rnatingItem)
{
CheckBox cb=ri.FindContr ol("Checkbox1" ) as CheckBox;
cb.CheckedChang ed +=new EventHandler(Ch eckedChanged);
}
}

private void CheckedChanged( object sender, EventArgs e)
{
CheckBox cb=(CheckBox)se nder;
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...@ne tzero.netwrote:
Sorry, forgot that you have asked for VB

Private Sub Repeater1_ItemC reated(ByVal sender As Object, ByVal e As
RepeaterItemEve ntArgs)
Dim ri As RepeaterItem = CType(e.Item, RepeaterItem)
If ri.ItemType = ListItemType.It em Or ri.ItemType =
ListItemType.Al ternatingItem Then
Dim cb As CheckBox = CType(ri.FindCo ntrol("Checkbox 1"), CheckBox)
AddHandler cb.CheckedChang ed, AddressOf Me.CheckedChang ed
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...@ne tzero.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...@ne tzero.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)sende r;
GridViewRow dgi;

dgi = (GridViewRow)my CheckBox.Parent .Parent;
string sInvoiceItemID = dgi.Cells[1].Text.Trim();
Trace.Write(sIn voiceItemID);

theMethodTodoRe alWork( 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
11792
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 me to access it. The funny thing is that it compiles fine, and the checkboxes are there, I just can't write to them! Is there a way around this problem? My HTML is as follows:
2
5051
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 until it comes time to implement paging. Without paging I can iterate through the repeater when I click 'Select All' and set the checked property to true for all items in the repeater. However when I implement paging, I have to rebind the repeater...
1
1408
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) whenever someone clicks on the checkbox? Also, how do I determine which checkbox was clicked so that I can run the appropriate code?
4
2708
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 a row or not to show, how do I accomplish that using a repeater control ? Should I do something like this <%if (((DataRowView)Container.DataItem) == 0) { %><asp:CheckBox ID="chkBookMarkID" text='<%#
2
6456
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 work. This is the code that I used to go thru the repeater control to find my checkboxes. foreach(RepeaterItem r in MyRepeater.Items)
4
7439
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 and the other for product cost. <%#Container.DataItem("ProductA")%> <%#Container.DataItem("PriceA")%>
0
2285
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 chkAll. I simply want to have chkAll be checked if every item in the repeater has its checkbox checked. In the code behind page, I can access the checked property of chkReconciled by doing the following: Dim CurrentCheckBox As CheckBox...
1
1850
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 tied to xsl, I added the checkbox there. That works fine, but I cannot get any information about the checkbox (i.e. checked, unchecked, etc) when I pass data from the xsl over to a method in java. I can get info on the other columns but not...
3
2913
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 that of the users of the project. I have used checkboxes for selecting the roles that a particular user has. For example, an adminstrator has all roles in an organisation. Similarly an Employee has limited roles. Here let us take administrator...
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2850
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.