DropDown List

Discussion in 'ASP .Net Web Controls' started by Manoj Paramu Das, Feb 10, 2005.

  1. DropDwonList.SelectedItem.Value returns only the first record value, no
    matter when you select. any help would be appreciated.

    Thnaks Manoj
    Manoj Paramu Das, Feb 10, 2005
    #1
    1. Advertising

  2. Manoj Paramu Das

    ranganh Guest

    ranganh, Feb 11, 2005
    #2
    1. Advertising

  3. Read this excerpt:


    Adding Controls at the Right Time
    We already know that when adding controls dynamically through the page's
    code portion the controls must be added on every postback. But when in the
    page lifecycle should the controls be added? At first guess, we might decide
    to put such code in the Page_Load event handler, causing the controls to be
    added during the Load stage of the page's lifecycle. This would work fine if
    we don't need to worry about saving the controls' view state across
    postbacks, but if we do need to persist the view state of the dynamically
    added controls the Load stage is not where we should be adding these
    controls.

    If we need our dynamically added controls to maintain their view state it is
    paramount that these controls be added before the Load View State stage.
    That is, these controls must exist within the page's control hierarchy
    before the view state is loaded. There's only one stage before Load View
    State - Initialization. That means, if we want our dynamic controls to
    persist view state we must add them to the control hierarchy in the page's
    Init event.

    If you are using Visual Studio .NET, the code-behind class already contains
    an event handler for the page's Init event. This event handler (named
    Page_Init in VB.NET code-behind classes and OnInit in C# code-behind
    classes) is tucked away in the hidden "Web Form Designer Generated Code"
    region. What I typically do is create a separate method in the code-behind
    class and simply call this method from the Init event handler. Once you have
    configured everything so that the dynamic controls are added during the
    Initialization stage, you can then read/write the controls' properties in
    the Load stage. You'll find that the users' interactions with the dynamic
    controls remains "remembered" across postbacks if you follow this pattern.



    That should help,











    "Manoj Paramu Das" <> wrote in message
    news:...
    > DropDwonList.SelectedItem.Value returns only the first record value, no
    > matter when you select. any help would be appreciated.
    >
    > Thnaks Manoj
    >
    Sean McKaharay, Feb 14, 2005
    #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. vishnu
    Replies:
    1
    Views:
    1,202
    Patrick.O.Ige
    Mar 25, 2006
  2. Mike
    Replies:
    1
    Views:
    802
  3. acadam
    Replies:
    0
    Views:
    754
    acadam
    Dec 27, 2006
  4. Replies:
    2
    Views:
    432
  5. Steve Myers
    Replies:
    2
    Views:
    271
    Steve Myers
    Nov 20, 2003
Loading...

Share This Page