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

Discussion in 'ASP .Net' started by Raed Sawalha, Oct 5, 2004.

  1. Raed Sawalha

    Raed Sawalha Guest

    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...
     
    Raed Sawalha, Oct 5, 2004
    #1
    1. Advertising

  2. Raed Sawalha

    Juno Guest

    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" <> wrote in message
    news:...
    > 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...
    >
    >
     
    Juno, Oct 5, 2004
    #2
    1. Advertising

  3. 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...
    >
    >
    >
     
    =?Utf-8?B?UHN5Y2hv?=, Oct 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RC
    Replies:
    1
    Views:
    600
    Teemu Keiski
    Jun 7, 2005
  2. JaM
    Replies:
    2
    Views:
    2,988
  3. msimmons
    Replies:
    0
    Views:
    525
    msimmons
    Jul 16, 2009
  4. Tatyana
    Replies:
    0
    Views:
    211
    Tatyana
    Jun 26, 2006
  5. Ashish Bhonkiya

    ProblemAccessing Controls inside HTMLTable created Dynamically

    Ashish Bhonkiya, Nov 3, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    121
    Ashish Bhonkiya
    Nov 3, 2003
Loading...

Share This Page