Reset DropDown to Default

Discussion in 'ASP .Net Web Controls' started by Thom Little, Aug 5, 2004.

  1. Thom Little

    Thom Little Guest

    I want to manually reset the DropDownList when using AutoPostBack to its
    default value that has entry 0 as the default.

    The following puts the select name and value in two labels and resets the
    dropdown to the default.

    private void ddlA_SelectedIndexChanged(object sender, System.EventArgs e )
    {
    string strValue = ddlA.SelectedItem.Value ;
    lblA.Text = ddlA.SelectedItem.Text;
    lblB.Text = strValue ;
    ddlA.SelectedIndex = 0 ;
    Response.Write( "" );
    }

    The following does not put the selected name and value in the two labels and
    does not reset the dropdown to the default but it does transfer to the URL
    in the selected value.

    private void ddlA_SelectedIndexChanged(object sender, System.EventArgs e )
    {
    string strValue = ddlA.SelectedItem.Value ;
    lblA.Text = ddlA.SelectedItem.Text;
    lblB.Text = strValue ;
    ddlA.SelectedIndex = 0 ;
    Response.Write( "" );
    Response.Redirect( "http://" + strValue );
    }

    How can I reset the index and also do the redirect?

    I can not disable the Cache because I want this code to work in browsers
    other than Internet Explorer.

    --
    -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    --
     
    Thom Little, Aug 5, 2004
    #1
    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. psinyc
    Replies:
    0
    Views:
    739
    psinyc
    Aug 6, 2003
  2. Mad Scientist Jr
    Replies:
    1
    Views:
    504
    Mad Scientist Jr
    Jun 25, 2004
  3. Peter Kellner

    How to reset the colors of a Label to Default

    Peter Kellner, Apr 19, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    385
    Peter Kellner
    Apr 19, 2006
  4. Thom Little

    Reset DropDown

    Thom Little, Aug 16, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    115
    Thom Little
    Aug 16, 2006
  5. Joey Martin

    Reset to default in SQL

    Joey Martin, Nov 15, 2003, in forum: ASP General
    Replies:
    2
    Views:
    125
    Joey Martin
    Nov 15, 2003
Loading...

Share This Page