Reset DropDown to Default

T

Thom Little

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,779
Messages
2,569,606
Members
45,239
Latest member
Alex Young

Latest Threads

Top