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

Edit data in a repeater?

P: n/a
Hi All

I am trying to find a way of displaying data in a datatable in such a way that ALL rows (only about 5 - 10) are editable and are updated from a single button press. I thought the best way would be to use a repeater to display the data in textboxes, then when the button is pressed to iterate through the repeater control and find all the text boxes and update the DB with the values, but I have come across a couple of problems

The main one that I need to solve is: how do I find each textbox control when I postback the data on the button press? If anyone has done this before, or has a better way of doing it, I would be grateful if you let me know

The repeater code on my page is

<asp:Repeater id="rptThreads" runat="server"><HeaderTemplate><table cellSpacing="1" cellPadding="1" border="0"></HeaderTemplate><ItemTemplate><TR><TD width="200">Doc Type(s)</TD><TD><asp:TextBox Text='<%# Container.DataItem("file_type") %>' size="60" runat="server"></asp:TextBox><asp:TextBox Text='<%# Container.DataItem("max_threads") %>' size="5" runat="server"></asp:TextBox></TD></TR></ItemTemplate><FooterTemplate></table></FooterTemplate></asp:Repeater>
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You can use
Repeater.Items[i].FindControl("controlName") and cast it to the respective
control.

Av.
"Steve" <ms**@zuna.co.uk> wrote in message
news:64**********************************@microsof t.com...
Hi All,

I am trying to find a way of displaying data in a datatable in such a way
that ALL rows (only about 5 - 10) are editable and are updated from a
single button press. I thought the best way would be to use a repeater to
display the data in textboxes, then when the button is pressed to iterate
through the repeater control and find all the text boxes and update the DB
with the values, but I have come across a couple of problems.

The main one that I need to solve is: how do I find each textbox control
when I postback the data on the button press? If anyone has done this
before, or has a better way of doing it, I would be grateful if you let me
know.

The repeater code on my page is:

<asp:Repeater id="rptThreads" runat="server"><HeaderTemplate><table
cellSpacing="1" cellPadding="1"
border="0"></HeaderTemplate><ItemTemplate><TR><TD width="200">Doc
Type(s)</TD><TD><asp:TextBox Text='<%# Container.DataItem("file_type") %>'
size="60" runat="server"></asp:TextBox><asp:TextBox Text='<%#
Container.DataItem("max_threads") %>' size="5"
runat="server"></asp:TextBox></TD></TR></ItemTemplate><FooterTemplate></table></FooterTemplate></asp:Repeater>

Nov 18 '05 #2

P: n/a
There is some code demonstrating exactly what you describe in the
following article:

http://odetocode.com/Articles/116.aspx

HTH,

--
Scott

On Fri, 14 May 2004 03:56:02 -0700, "Steve" <ms**@zuna.co.uk> wrote:
Hi All,

I am trying to find a way of displaying data in a datatable in such a way that ALL rows (only about 5 - 10) are editable and are updated from a single button press. I thought the best way would be to use a repeater to display the data in textboxes, then when the button is pressed to iterate through the repeater control and find all the text boxes and update the DB with the values, but I have come across a couple of problems.

The main one that I need to solve is: how do I find each textbox control when I postback the data on the button press? If anyone has done this before, or has a better way of doing it, I would be grateful if you let me know.

The repeater code on my page is:

<asp:Repeater id="rptThreads" runat="server"><HeaderTemplate><table cellSpacing="1" cellPadding="1" border="0"></HeaderTemplate><ItemTemplate><TR><TD width="200">Doc Type(s)</TD><TD><asp:TextBox Text='<%# Container.DataItem("file_type") %>' size="60" runat="server"></asp:TextBox><asp:TextBox Text='<%# Container.DataItem("max_threads") %>' size="5" runat="server"></asp:TextBox></TD></TR></ItemTemplate><FooterTemplate></table></FooterTemplate></asp:Repeater>


--
Scott
http://www.OdeToCode.com
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.