Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to get the TextBox Value in a dynamically created HtmlTable???

Reply
Thread Tools

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

 
 
Raed Sawalha
Guest
Posts: n/a
 
      10-05-2004
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...


 
Reply With Quote
 
 
 
 
Juno
Guest
Posts: n/a
 
      10-05-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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...
>
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?UHN5Y2hv?=
Guest
Posts: n/a
 
      10-05-2004
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...
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
GridView: cannot get data from dynamically created Textbox JaM ASP .Net 2 10-04-2006 10:36 AM
Catch TextBox value entered by user into the GridView Templated Field (both created dynamically) on PostBack Tatyana ASP .Net Datagrid Control 0 06-26-2006 03:03 PM
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created) dickster ASP .Net Building Controls 0 12-08-2005 09:32 AM
Get Value From Dynamically Created TextBoxes...... RC ASP .Net 1 06-07-2005 05:44 AM



Advertisments