i have a asp form ,in which i have few controls,there is a drop down value ,i want to show and hide followings fields base on the value selected from the drop down,problem is there is not one value against i want to show or hide the fields ,there are more then two values asp code is
Code
EmployeeStatus:code behind is
TypeScript
protected void ddlEmpStatus_SelectedIndexChanged(object sender, EventArgs e) { if (ddlEmpStatus.SelectedValue == "Absent") { ddlDutyType.Visible = false; ddlEmployeeShift.Visible = false; txtEndDate.Visible = false; txtHasWirles.Visible = false; } else { txtStartDate.Visible = true; txtEndDate.Visible = true; ddlDutyType.Visible = true; ddlEmployeeShift.Visible = true; } }

Khargesh RajputRank #616 · 3.9K reputationPosted Jan 5, 2015, 6:39 PM EST
you can check selected values of ddl and then according to condition set visible false to label
Vinodh NarayananRank #175 · 13.8K reputationPosted Jan 5, 2015, 7:12 PM EST
default.aspx.cs
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if(DropDownList1.SelectedIndex == 1)
{
txtleave.Visible = false;
txtshort.Visible = false;
txtlong.Visible = false;
lblleave.Visible = false;
lbllong.Visible = false;
lblshort.Visible = false;
}
else if(DropDownList1.SelectedIndex == 2)
{
txtleave.Visible = false;
txtshort.Visible = false;
txtlong.Visible = false;
lblleave.Visible = false;
lbllong.Visible = false;
lblshort.Visible = false;
}
else
{
txtleave.Visible = true;
txtshort.Visible = true;
txtlong.Visible = true;
lblleave.Visible = true;
lbllong.Visible = true;
lblshort.Visible = true;
}
}
Please mark if accepted as answer