473,387 Members | 1,899 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 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='<%#DataBinder.Eval(Container, "DataItem.Module")%>'>
</asp:CheckBox>
</td>
<td>
Pris:
<%#DataBinder.Eval(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 11748
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.FindControl
("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:Repeater ID="Overview" Runat="server" Visible="False"> <ItemTemplate>
<tr>
<td width="200">
<asp:CheckBox ID="chkModule" Enabled=True Runat="server"Text='<%#DataBinder.Eval(Container, "DataItem.Module")%>'>
</asp:CheckBox>
</td>
<td>
Pris:
<%#DataBinder.Eval (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 #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:

OverviewRepeater.DataBinding += new
Eventhandler(this.OverviewRepeater_DataBinding); //Just initializing the
eventhandler here.

//And here's the handler function called on every databind.
private void OverviewRepeater_DataBinding(object 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*******@discussions.microsoft.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.FindControl
("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:Repeater ID="Overview" Runat="server"

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

Runat="server"
Text='<%#DataBinder.Eval(Container, "DataItem.Module")%>'>
</asp:CheckBox>
</td>
<td>
Pris:
<%#DataBinder.Eval

(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 #3

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

Similar topics

3
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
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...
8
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...
2
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...
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: 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...
5
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...
1
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"...
3
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
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
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.