How to get particular item in list in c#?

Posted by Iluvdotnetfunda under ASP.NET on 8/10/2012 | Points: 10 | Views : 1033 | Status : [Member] | Replies : 1
Hello Friends,

I have a dropdownlist with two list items Enable and Disable.
when user selects enable button and click on submit, page will be redirected and dropdownlist must change to disable button.
How can we achieve this?

Thanks
iluvdotnetfunda




Responses

Posted by: Ranjeet_8 on: 8/10/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
HTML
 

<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Enable</asp:ListItem>
<asp:ListItem>Disable</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

C#

protected void Button1_Click(object sender, EventArgs e)
{
if (DropDownList1.SelectedItem.Text == "Enable")
DropDownList1.SelectedIndex = 1;
else
DropDownList1.SelectedIndex = 0;
}


Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response