In previous post we have seen how to get the drop down selected value.In this post i will show how to get the selected index value in asp.int using c#.net.Here i have used one drop down list and label to display index value.
Code:
AutoPostBack="True">
<asp:ListItem>Please select</asp:ListItem>
<asp:ListItem>Hyderabad</asp:ListItem>
<asp:ListItem>Chennai</asp:ListItem>
<asp:ListItem>Bombay</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lbly" runat="server" Text="Label"></asp:Label>
Code:
protected void dtest_SelectedIndexChanged(object sender, EventArgs e) { lbly.Text = dtest.SelectedIndex.ToString(); } aspx:<asp:DropDownList ID="dtest" runat="server" onselectedindexchanged="dtest_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem>Please select</asp:ListItem>
<asp:ListItem>Hyderabad</asp:ListItem>
<asp:ListItem>Chennai</asp:ListItem>
<asp:ListItem>Bombay</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lbly" runat="server" Text="Label"></asp:Label>
No comments:
Post a Comment