473,769 Members | 5,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checkbox inside a repeater control..

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:

<asp:Repeater ID="Overview" Runat="server" Visible="False" >
<ItemTemplate >
<tr>
<td width="200">
<asp:CheckBox ID="chkModule" Enabled=True Runat="server"
Text='<%#DataBi nder.Eval(Conta iner, "DataItem.Modul e")%>'>
</asp:CheckBox>
</td>
<td>
Pris:
<%#DataBinder.E val(Container, "DataItem.Price ")%>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>

This compiles fine, but if I go to the code view and tries to write
"this.chkModule ...." it isn't recognized!

Thanks for your help,

Thomas Regin.
Nov 18 '05 #1
2 11791
Because the checkbox is contained within a repeater
control, it is now a child of the repeater control and you
cannot access it directly the way you are trying. (just
remember there could be any number of instances of this
checkbox, one for each record in your repeater control)

You need to access the checkbox in the repeaters
onDataBind event to set the value for it.

Eg.
Dim myCheckbox As CheckBox
myCheckBox = CType(e.Item.Fi ndControl
("myCheckBox"), CheckBox)

this code would be typically placed in the databind event
and the variable 'e' would be an eventArgs parameter.

Hope this helps

-----Original Message-----
Is is possible?

In VS.NET 2003, Binding data to the repeater is easy, but when I try to addan ASP:checkbox to the .aspx page, the designer won't recognize it, hencethe code view doesn't allow me to access it. The funny thing is that itcompiles 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:

<asp:Repeate r ID="Overview" Runat="server" Visible="False" > <ItemTemplate >
<tr>
<td width="200">
<asp:CheckBox ID="chkModule" Enabled=True Runat="server"Text='<%#DataB inder.Eval(Cont ainer, "DataItem.Modul e")%>'>
</asp:CheckBox>
</td>
<td>
Pris:
<%#DataBinder.E val (Container, "DataItem.Price ")%> </td>
</tr>
</ItemTemplate>
</asp:Repeater>

This compiles fine, but if I go to the code view and tries to write"this.chkModul e...." it isn't recognized!

Thanks for your help,

Thomas Regin.
.

Nov 18 '05 #2

Rory,

Thank you for your answer!

The problem is, that I need/would like to access the checkboxes at design
time, and set their on/off status while binding the repeater control. How
would I do that using the eventhandler?

I am a C# developer, and this is what I have:

OverviewRepeate r.DataBinding += new
Eventhandler(th is.OverviewRepe ater_DataBindin g); //Just initializing the
eventhandler here.

//And here's the handler function called on every databind.
private void OverviewRepeate r_DataBinding(o bject sender, EventArgs e)
{
//What should I do here? Add bool on/off checkbox argument to this
function like "bool isChecked"?
}

I am not sure that the above would work, hence I don't see how I can set the
state of a checkbox at design time. The only way is to iterate through the
checkboxes afterwards and set their state, but that is a really stupid,
inefficient approach if you ask me!

Thanks for your help again, I hope that you or someone else can help med
solve this! :)

Thomas Regin.
"Rory" <an*******@disc ussions.microso ft.com> wrote in message
news:2e******** *************** *****@phx.gbl.. .
Because the checkbox is contained within a repeater
control, it is now a child of the repeater control and you
cannot access it directly the way you are trying. (just
remember there could be any number of instances of this
checkbox, one for each record in your repeater control)

You need to access the checkbox in the repeaters
onDataBind event to set the value for it.

Eg.
Dim myCheckbox As CheckBox
myCheckBox = CType(e.Item.Fi ndControl
("myCheckBox"), CheckBox)

this code would be typically placed in the databind event
and the variable 'e' would be an eventArgs parameter.

Hope this helps

-----Original Message-----
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:

<asp:Repeate r ID="Overview" Runat="server"

Visible="False" >
<ItemTemplate >
<tr>
<td width="200">
<asp:CheckBox ID="chkModule" Enabled=True

Runat="server"
Text='<%#DataB inder.Eval(Cont ainer, "DataItem.Modul e")%>'>
</asp:CheckBox>
</td>
<td>
Pris:
<%#DataBinder.E val

(Container, "DataItem.Price ")%>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>

This compiles fine, but if I go to the code view and

tries to write
"this.chkModul e...." it isn't recognized!

Thanks for your help,

Thomas Regin.
.

Nov 18 '05 #3

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

Similar topics

3
4852
by: Jack Turnbull | last post by:
Hi, I have a Checkbox in a Repeater set to AutoPostBack = true. I have pointed OnCheckedChanged to a Sub but it doesn't fire. If I move the checkbox out of the Repeater it fires! Any ideas? Thanks
2
6455
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)
8
16617
by: Alan Silver | last post by:
Hello, I have a repeater that has code like this... <ItemTemplate> <asp:CheckBox ID="chkDelete" Text="" RunAt="server"/> .... other stuff goes here </ItemTemplate> There is a button below the repeater. When clicked, it is supposed to
2
3717
by: RichardH | last post by:
Hi, I have x number of table rows that all should have a checkbox and a dropdownlist on each row. The checkbox could be checked and the dropdown should contain y number of values that are related to the row. I can't find a good control for this in ASP.Net 2.0. Now I use a repeater and check the checkbox on ItemDataBound, I also fill the dropdown on this event. My first problem is that i find this event very messy. I have to cast...
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...
0
1729
by: deathtospam | last post by:
A few weeks ago, I created a Classic ASP page that connects to a machine with SQL Server installed on it, prompts the user to select a database on that server, then lists all of user-created stored procedures in that database. The user can select any of those stored procedures by clicking on checkboxes; after submitting their selections, a script to delete and then re-create each stored procedure will be generated. Now I'm trying to do...
5
24527
by: c_shah | last post by:
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
1
1912
by: Doogie | last post by:
Why is this code not allowing me to add a checkbox to it? <asp:repeater ID="RptTrip" Runat="server" EnableViewState="false"> <ItemTemplate> <asp:Checkbox AutoPostBack="True" ID="cb" runat="server" Checked="false"></asp:Checkbox> <trip_detail_info trip_detail_id ='<%# Container.DataItem("trip_detail_id")%>' leg_start_dt = '<%# Container.DataItem("leg_start_dt")%>' pickup_iso_dt = '<%# Container.DataItem("pickup_iso_dt")
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
9423
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
10210
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
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7406
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
6672
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
5298
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...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3956
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 we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.