By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,635 Members | 1,691 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,635 IT Pros & Developers. It's quick & easy.

how do I add textbox in a repeater

P: n/a
Well... with data in the textbox..
This did not work...

<asp:TableCell ID="Tablecell1" CssClass="lnk_results" Runat="server"
Width="35%" HorizontalAlign="Left" ColumnSpan="5">
<asp:TextBox id="TextBoxMessage" runat="server"
TextMode="MultiLine" Width="248px" Height="80px"><%#
DataBinder.Eval(Container.DataItem, "Item_Description") %></asp:TextBox>
</asp:TableCell>

Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Repeaters are for read only display of data. Better try a DataList or
DataGrid.
"Dave" <da***@helixpoint.com> wrote in message
news:OV**************@TK2MSFTNGP14.phx.gbl...
Well... with data in the textbox..
This did not work...

<asp:TableCell ID="Tablecell1" CssClass="lnk_results" Runat="server"
Width="35%" HorizontalAlign="Left" ColumnSpan="5">
<asp:TextBox id="TextBoxMessage" runat="server"
TextMode="MultiLine" Width="248px" Height="80px"><%#
DataBinder.Eval(Container.DataItem, "Item_Description") %></asp:TextBox>
</asp:TableCell>

Nov 19 '05 #2

P: n/a
Same thing in a datagrid????

"Scott M." <s-***@nospam.nospam> wrote in message
news:Ov**************@TK2MSFTNGP15.phx.gbl...
Repeaters are for read only display of data. Better try a DataList or
DataGrid.
"Dave" <da***@helixpoint.com> wrote in message
news:OV**************@TK2MSFTNGP14.phx.gbl...
Well... with data in the textbox..
This did not work...

<asp:TableCell ID="Tablecell1" CssClass="lnk_results" Runat="server"
Width="35%" HorizontalAlign="Left" ColumnSpan="5">
<asp:TextBox id="TextBoxMessage" runat="server"
TextMode="MultiLine" Width="248px" Height="80px"><%#
DataBinder.Eval(Container.DataItem, "Item_Description") %></asp:TextBox>
</asp:TableCell>


Nov 19 '05 #3

P: n/a
You need to databind Text property:

Text="<%# DataBinder.Eval(Container.DataItem, "Item_Description") %>"

Eliyahu

"Dave" <da***@helixpoint.com> wrote in message
news:OV**************@TK2MSFTNGP14.phx.gbl...
Well... with data in the textbox..
This did not work...

<asp:TableCell ID="Tablecell1" CssClass="lnk_results" Runat="server"
Width="35%" HorizontalAlign="Left" ColumnSpan="5">
<asp:TextBox id="TextBoxMessage" runat="server"
TextMode="MultiLine" Width="248px" Height="80px"><%#
DataBinder.Eval(Container.DataItem, "Item_Description") %></asp:TextBox>
</asp:TableCell>

Nov 19 '05 #4

P: n/a
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

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.