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

How to get the TextBox Value in a dynamically created HtmlTable???

P: n/a
Hi,

This is probably pretty simple but...

I am dynamically adding rows to a HtmlTable that contain Textbox controls.
(There may be more than one server control/textbox in a given cell)

How do I get the value of a textbox when the form is posted back?

I would expect something like:

TextBox t = (TextBox)Table1.Rows[0].Cells[0].Controls[0];
String s = t.Text;

(I may be using the controls colletion incorrectly...)

Or at least that is the kind of solution I'm looking for...
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

Table cann't persist its status between postback. So you have to create it
every time and add controls as well.

Or you can use request.form("yourtextboxid") to get textbox value directly.
But you still need to create table to display on the page.

--
Juno
MCSD.NET, MCDBA, MCSE
----------------------------------------------------------
Support Team of EasyDotNet, INC. http://www.EasyDotNet.com
DataForm.NET - The most powerful data entry web server control for ASP.NET

"Raed Sawalha" <ra**********@hotmail.com> wrote in message
news:Om**************@TK2MSFTNGP10.phx.gbl...
Hi,

This is probably pretty simple but...

I am dynamically adding rows to a HtmlTable that contain Textbox controls.
(There may be more than one server control/textbox in a given cell)

How do I get the value of a textbox when the form is posted back?

I would expect something like:

TextBox t = (TextBox)Table1.Rows[0].Cells[0].Controls[0];
String s = t.Text;

(I may be using the controls colletion incorrectly...)

Or at least that is the kind of solution I'm looking for...

Nov 18 '05 #2

P: n/a
from my part of view this is not simply at all.
first you should make an custom control derived from textbox which implement
IPostBackDataHandler and on
public bool LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection)
save somewhere in session your data. Session["key"] =
postCollection[postDataKey].ToString();
You cand override prerender on control to put your data back. this.Text =
Session["key"].ToString();
I think you better make a class to do this stuff for saving and getting you
data from session for all your dynamical controls.
So, this is very simple. :)

"Raed Sawalha" wrote:
Hi,

This is probably pretty simple but...

I am dynamically adding rows to a HtmlTable that contain Textbox controls.
(There may be more than one server control/textbox in a given cell)

How do I get the value of a textbox when the form is posted back?

I would expect something like:

TextBox t = (TextBox)Table1.Rows[0].Cells[0].Controls[0];
String s = t.Text;

(I may be using the controls colletion incorrectly...)

Or at least that is the kind of solution I'm looking for...

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.