Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have asp.net dropdownlist some thing like
<asp:DropDownList ID="reservation1"  CssClass="tel" runat="server">
                             <asp:ListItem Value="0">--Select--</asp:ListItem>
                             <asp:ListItem Value="1">General</asp:ListItem>
                             <asp:ListItem Value="2">SC/ST</asp:ListItem>
                             <asp:ListItem Value="3">Others</asp:ListItem>
                         </asp:DropDownList>

inside form.after submitting details i want to set above dropdown value or to "0" or "--Select--" in code behind

What I have tried:

i have tried by makeig AppendDataBoundItems=true still not able to get it
Posted
Updated 12-Apr-16 23:14pm

1 solution

use SelectedIndex [^] property
C#
reservation1.SelectedIndex = 0;
 
Share this answer
 
Comments
Veena Hosur 13-Apr-16 5:23am    
i have tried it,its taking index value but in form that text is not displaying
Karthik_Mahalingam 13-Apr-16 5:39am    
what is displaying on screen ?
Veena Hosur 13-Apr-16 6:00am    
its displaying next item of what i have selected before submition
Karthik_Mahalingam 13-Apr-16 6:07am    
i have did this

<form id="form1" runat="server">

<asp:DropDownList ID="reservation1" CssClass="tel" runat="server">
<asp:ListItem Value="0">--Select--
<asp:ListItem Value="1">General
<asp:ListItem Value="2">SC/ST
<asp:ListItem Value="3">Others

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click2" />

</form>


protected void Button1_Click2(object sender, EventArgs e)
{
reservation1.SelectedIndex = 0;
}


it works perfect..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900