How does a dynamic control load post back data across post back??

Discussion in 'ASP .Net' started by =?Utf-8?B?Z29yaWxsYQ==?=, May 25, 2007.

  1. As we know , the view state is not responsible for having TextBoxes,
    CheckBoxes, DropDownLists, and other Web controls remember their values
    across postback.

    When I dynamically add a DropDownList in the web,and dynamically add the
    items in it.

    such as:

    void Page_Load(Object sender, EventArgs e)
    {
    DropDownList ddlDynamic = new DropDownList();
    ddlDynamic.ID = "ddlDynamic";

    form1.Controls.Add(ddlDynamic);

    if (!IsPostBack)
    {
    for (int i=1; i <=3; i++)
    ddlDynamic.Items.Add(new ListItem(i.ToString(), i.ToString()));
    }

    I check the second value of the DropDownList.

    when post back ,I can see the dynamically items,and the checked value is
    what I have checked.

    I know that the viewstate of the DropDownList can be loaded by the method
    form1.Controls.Add(ddlDynamic) during post back,but I don't know how does the
    check value be loaded during post back.
    please help me.
     
    =?Utf-8?B?Z29yaWxsYQ==?=, May 25, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?Z29yaWxsYQ==?=

    Masudur Guest

    gorilla wrote:
    > As we know , the view state is not responsible for having TextBoxes,
    > CheckBoxes, DropDownLists, and other Web controls remember their values
    > across postback.
    >
    > When I dynamically add a DropDownList in the web,and dynamically add the
    > items in it.
    >
    > such as:
    >
    > void Page_Load(Object sender, EventArgs e)
    > {
    > DropDownList ddlDynamic = new DropDownList();
    > ddlDynamic.ID = "ddlDynamic";
    >
    > form1.Controls.Add(ddlDynamic);
    >
    > if (!IsPostBack)
    > {
    > for (int i=1; i <=3; i++)
    > ddlDynamic.Items.Add(new ListItem(i.ToString(), i.ToString()));
    > }
    >
    > I check the second value of the DropDownList.
    >
    > when post back ,I can see the dynamically items,and the checked value is
    > what I have checked.
    >
    > I know that the viewstate of the DropDownList can be loaded by the method
    > form1.Controls.Add(ddlDynamic) during post back,but I don't know how does the
    > check value be loaded during post back.
    > please help me.



    --->>>>"I know that the viewstate of the DropDownList can be loaded by
    the method
    form1.Controls.Add(ddlDynamic) during post back,"

    if your checked value is already selected then what is the
    problem....???

    ---->>>>"but I don't know how does the check value be loaded during
    post back."

    i dont get it loading the same control with same id did all to save
    and persists the values....
    if you want to do some business with the value just subscribe the
    SelectedIndexChanged event of dropdown list.

    Thanks
    Masudur
     
    Masudur, May 25, 2007
    #2
    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. sk2000
    Replies:
    2
    Views:
    4,486
    Kumar
    Nov 12, 2003
  2. =?Utf-8?B?QWxla3NhbmRhciBBbmRqZWxrb3ZpYw==?=

    Refresh data grid control without (post back)

    =?Utf-8?B?QWxla3NhbmRhciBBbmRqZWxrb3ZpYw==?=, May 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,142
    mortb
    May 24, 2004
  3. John Hoge

    Persisting form data across page load

    John Hoge, Nov 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    411
    =?Utf-8?B?S3Jpc2g=?=
    Nov 29, 2004
  4. rjl

    page load/post back

    rjl, Dec 21, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    706
    Tasos Vogiatzoglou
    Jan 5, 2006
  5. Larry Bud
    Replies:
    1
    Views:
    367
    bruce barker
    Jan 10, 2007
Loading...

Share This Page