Farooque Ali

Farooque Ali

  • 1.5k
  • 255
  • 242.8k

Dropdown SelectedIndex Item in MVC Application

Sep 7 2010 3:11 AM

I have created in the Dropdown list in the MVC Application.Also I have get the value from by giving thru the function.  Question is: If i select the 1st item from the Dropdown menu from the list, i do not want to display the label control in the form. If i select the 2 option from the Dropdown i want to display the Label Control
So i have to write the SelectIndex Method in the application. Please tell me how to write the SelectedIndex Method in the MVC application?
In the Form I have written AddRule.aspx
<%
= Html.DropDownList("gs1")%>
In the Controller
ViewData[
"gs1"] = new List<SelectListItem>
{
new SelectListItem
{
Text =
"Select",
Value =
"0",
Selected =
false
},
new SelectListItem
{
Text =
"(",
Value =
"1",
},
new SelectListItem
{
Text =
")",
Value =
"2",
}
};
In the Model,
[
Required]
[
DataType(DataType.Text)]
public IEnumerable<SelectListItem> gs1 { get; set; }
 

Answers (1)