473,320 Members | 1,900 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,320 software developers and data experts.

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="txtFirstName"
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.FindControl("txtFirstName");
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*****@rocketmail.com

08.16.2005

Nov 19 '05 #1
0 10418

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

Similar topics

1
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...
2
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...
5
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...
3
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. ...
2
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"> <%#...
0
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...
8
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...
0
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"...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.