473,545 Members | 937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get value from asp:textbox inside Repeater

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).

If EnableViewState ="True", the FindControl finds a 'copy'
of the asp:textbox control with it's initial value; not the postback
value. The postback value (whatever you type in the textbox AFTER the
page has loaded seems to get overridden because there is already a
control in memory with your texbox name). In my case FindControl
returns the Text property of the textbox as "".

Anyway, here's the solution:

--------------------
-------------------- ASPX
--------------------
<asp:Repeater
ID="Repeater1"
EnableViewState ="False"
runat="server">

<ItemTemplate >

<asp:TextBox
ID="txtFirstNam e"
runat="server"/>

</ItemTemplate>

</asp:Repeater>

--------------------
-------------------- C#
--------------------
foreach (RepeaterItem item in Repeater1.Items )
{
Response.Write( ((TextBox)item. Controls[1]).Text);
}

-------------------- OR

foreach (RepeaterItem item in Repeater1.Items )
{
TextBox FirstName = (TextBox)item.F indControl("txt FirstName");
Response.Write( FirstName.Text) ;
}

I'm using Visual Web Developer 2005 Express Edition Beta running .NET
version 2_0_50215 on Windows 2000 Professional.

Hope this helps,
Bill
da*****@rocketm ail.com

08.16.2005

Nov 19 '05 #1
0 10481

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

Similar topics

1
4538
by: etantonio | last post by:
Good Morning, I still havent solved my problem with a textbox inside an editItemTemplate of a datalist, in fact now it is filled with the word "CIAOOOOOO" , if a runtime in the form I put a different word like "PIZZAAAA" this new word is not available in the Update_Command following :
2
3796
by: Peter Kirk | last post by:
Hi are there any "gotchas" with using an asp:repeater that means that the "onclick" method of a LinkButton created in the repaeter does not fire? I at least cannot get it to work. I have a webpage where the user can enter some search criteria (via dropdowns and textboxes) and then perform a search and have results presented. The results...
5
8244
by: Scott Lyon | last post by:
I am having a strange problem. The program is a bit complex, but I'll try to simplify what I can. I apologize if this is complicated, but I think this would still be simpler than posting a bunch of source code. If you want me to post code, though, just say so. In a nutshell, I've got an ASP.NET application that has one main ASPX page. On...
3
2041
by: Kelly Leahy | last post by:
I'm using an Asp:Repeater control with a text box in the item templates. This is for a system that has a number of items that the user can edit and I'd like to generate them based on a list. However, when the user clicks a save button (not in the asp:repeater, but on the form itself) I would like to (on postback) update the values in the...
2
1386
by: Craig Buchanan | last post by:
I have an asp:textbox embedded in a repeater. I would like to default a value in the textbox, but when I try to use the format: <asp:textbox id="qty" runat="server"> <%# DataBinder.Eval(Container.DataItem,"Quantity") %> </asp:textbox> I get an error. Do I need to set the value in code?
0
1416
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"...
8
3436
by: dhnriverside | last post by:
Hi I'm using an asp:repeater and its DataSource/DataBind system to show a number of records from the database. I want to highlight the latest record (which will be the highest ID). Any thoughts on how to do this with the repeater? Cheers
0
1595
by: CharlesA | last post by:
Hi folks, I'm using ASP.net 1.1 with C# I've got this kind of thing going <div class="row"> <label class="col1">Rm Name</label> <asp:textbox id="txtRM" runat="server" cssclass="col2" ReadOnly="True" EnableViewState="False"></asp:textbox> <label class="col3">Rm Phone</label> <asp:textbox id="txtRmPhone" runat="server" cssclass="col4"...
1
17026
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater control in my aspx page with two image buttons, one for an edit command, another a delete command. Here is a cut down code fragment. ...
0
7467
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...
0
7656
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. ...
0
7807
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...
1
7419
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...
0
5971
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4944
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...
0
3450
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...
1
1879
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
0
703
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...

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.