473,801 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Textbox Control in a Repeater in ASP.Net

I am attempting to print out a table using a repeater in which one field is
updatable. Basically you would have a table of x number of rows and y number
of columns. However: only one field in each row will be updatable. My
thought was to build a repeater and then one of the <ItemTemplate > would be a
textbox where the user can update the values in each.

How would I go about in the code-behind to reference each textbox? My
texbox definintion is: <asp:Textbox ID="cID"......

Is an array created and I loop through the array? Just not sure how to
handle this.

Thanks for any help
Andy
Nov 17 '05 #1
4 24765
why not loop thorugh the repeater item and find the control you want using
the control id and then set the readonly value as required.

i.e

for(int i = 0; i < repeater.Items. Count; i++)
{
TextBox tb = repeater.Items[i].FindControl("c ID");
...
...
}

HTH

Ollie Riches

"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:80******** *************** ***********@mic rosoft.com...
I am attempting to print out a table using a repeater in which one field is
updatable. Basically you would have a table of x number of rows and y
number
of columns. However: only one field in each row will be updatable. My
thought was to build a repeater and then one of the <ItemTemplate > would
be a
textbox where the user can update the values in each.

How would I go about in the code-behind to reference each textbox? My
texbox definintion is: <asp:Textbox ID="cID"......

Is an array created and I loop through the array? Just not sure how to
handle this.

Thanks for any help
Andy

Nov 17 '05 #2
Thanks for the response.

Originally I thought I was doing something wrong: as I had the following
line:
foreach(Repeate rItem dataItem in rpRepeater.Item s)

which was not bringing anything back. However: when I use your line as
well: the count is returned at 0 and the for loop exits immediately.

When viewing the page, I have upwards of 45 rows, so I know there are items.
What am I missing?

Thanks
Andy

"Ollie Riches" wrote:
why not loop thorugh the repeater item and find the control you want using
the control id and then set the readonly value as required.

i.e

for(int i = 0; i < repeater.Items. Count; i++)
{
TextBox tb = repeater.Items[i].FindControl("c ID");
...
...
}

HTH

Ollie Riches

"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:80******** *************** ***********@mic rosoft.com...
I am attempting to print out a table using a repeater in which one field is
updatable. Basically you would have a table of x number of rows and y
number
of columns. However: only one field in each row will be updatable. My
thought was to build a repeater and then one of the <ItemTemplate > would
be a
textbox where the user can update the values in each.

How would I go about in the code-behind to reference each textbox? My
texbox definintion is: <asp:Textbox ID="cID"......

Is an array created and I loop through the array? Just not sure how to
handle this.

Thanks for any help
Andy


Nov 17 '05 #3
NEvermind: your code was working. I had the ViewState=false which was
causing the issue in the backend.

Sorry for all the dumb questions ;-)

Thanks so much for the help though. I appreciaate it, but it was another
ID-10T error ;-)

"Ollie Riches" wrote:
why not loop thorugh the repeater item and find the control you want using
the control id and then set the readonly value as required.

i.e

for(int i = 0; i < repeater.Items. Count; i++)
{
TextBox tb = repeater.Items[i].FindControl("c ID");
...
...
}

HTH

Ollie Riches

"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:80******** *************** ***********@mic rosoft.com...
I am attempting to print out a table using a repeater in which one field is
updatable. Basically you would have a table of x number of rows and y
number
of columns. However: only one field in each row will be updatable. My
thought was to build a repeater and then one of the <ItemTemplate > would
be a
textbox where the user can update the values in each.

How would I go about in the code-behind to reference each textbox? My
texbox definintion is: <asp:Textbox ID="cID"......

Is an array created and I loop through the array? Just not sure how to
handle this.

Thanks for any help
Andy


Nov 17 '05 #4

"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:80******** *************** ***********@mic rosoft.com...
I am attempting to print out a table using a repeater in which one field is updatable. Basically you would have a table of x number of rows and y number of columns. However: only one field in each row will be updatable. My
thought was to build a repeater and then one of the <ItemTemplate > would be a textbox where the user can update the values in each.

How would I go about in the code-behind to reference each textbox? My
texbox definintion is: <asp:Textbox ID="cID"......

Is an array created and I loop through the array? Just not sure how to
handle this.

For setting the value, use the ItemDataBound event:

private void Repeater1_ItemD ataBound(object sender,
System.Web.UI.W ebControls.Repe aterItemEventAr gs e)
{
if ( e.Item.ItemType == ListItemType.It em )
{
TextBox myTextBox = (TextBox)e.Item .FindControl("T extBoxName");
myTextBox.Text = "Some Text"; // use "e.Item.DataIte m" to get data from
a bound data source.
}
}
To read the user's changes:

foreach ( RepeaterItem item in Repeater1.Items )
{
if ( item.ItemType == ListItemType.It em)
{
TextBox myTextBox = (TextBox)e.Item .FindControl("T extBoxName");
// do something with "myTextBox.Text "
}
}
Nov 17 '05 #5

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

Similar topics

2
5838
by: Neil | last post by:
Is there an editable RTF textbox control which allows the user to apply bold, italic, etc.? I tried the Microsoft Rich Textbox Control, but there doesn't seem to be a way to allow the user to change the formatting while typing text. Is there such a beast? Thanks, Neil
3
2245
by: Ryan Joseph So | last post by:
Hi, I've been searching the web for custom textbox control that doesn't inherit from Windows textbox control but cannot find one. I've been trying to make my own custom textbox but I just dont know how to do it. Can anyone out there help me out how to make one. Just a simple textbox so i could understand how to make it. This is my first time to make custom control so i still have much to learn. Thanks.
5
9000
by: Quan Nguyen | last post by:
How can I obtain the textbox (editing field) control of the combobox? I tried combobox.Controls to obtain the collection of controls that the combobox contains but it turned out to be empty. Thanks.
1
3046
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! Can any one point me in direction of modify a TextBox control. What i want to do is to add a button, like the ComboBox have. with my own bitmap and execute an Event when clicked. I will use this to bring a lookup table when searching for customers.
4
2169
by: RTM | last post by:
Can anyone help me with the following issue? I've seen some similar questions here, but none relating to a textbox control.... I have a form with several controls, one of them being a textbox control with AutoPostBack set to true. I need to fire a method ONLY when the form has posted back due to a button click (no problem here), or from the user typing text in the text box and hitting enter. I can't call this method from any postback,...
0
1441
by: Luis Esteban Valencia | last post by:
am trying to databind within an asp:textbox control. I have tried many variations found here but nothing seems to work. It works fine if I use a regular HTML textbox input though. Here is what I have tried: <asp:textbox id='<%#DataBinder.Eval(Container.DataItem, "EmailID")%>' cssclass="textbox" runat="server"><%#DataBinder.Eval(Container.DataItem, "Email")%></asp:textbox> I get '<%# DataBinder.Eval(Container.DataItem,...
0
10557
by: datakix | last post by:
After 16 hours of frustration, I've managed to solve this problem for a project I'm working on. The 'trick' is set EnableViewState="False" for the asp:textbox inside the Repeater control. The problem is that by default the asp:textbox ViewState is True. This means that the textbox value is automatically preserved between postback (saved in the __VIEWSTATE hidden field and restored during a page postback).
2
2241
by: fabrice | last post by:
Hi, I have a trouble with my TextBox Control and it's ViewState in my form... The property for it, is FALSE as following : <form id="frmSearchBre4" runat="Server"> <asp:textbox id="myID" TabIndex="1" EnableViewState="false" MaxLength="50" runat="server" TextMode="SingleLine"> </asp:textbox>
2
1297
by: Neo Geshel | last post by:
I am looking to add additional data into a "stream" that has been extracted from a database, but before it is sent to a control (Repeater, in this case). I have found ZERO (0) articles about this on the Internet. Anyone care to point me in the right direction? I am not looking for code that rivals Gray's Anatomy in complexity, just something that can add a static variable in a line or two of code (at the most). My script so far...
0
9556
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
10516
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
10292
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...
0
10052
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
7589
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
5479
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
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2959
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.