I have three DropdownList
named
- drpUniversity
- drpFaculty
- drpSupervisor
in my page.
In drpUniversity
has a list of University and in last index has Others if the listed Universities are not sufficient for users.
Like as:
- American University,
- George Washington University,
- Florida Hospital College of Health Sciences
- and Others
Now, in the drpUniversity_SelectedIndexChange
event I have add a Label
and a TextBox
when the user select the Others (or last index).
My Code:
protected void drpUniversity_SelectedIndexChanged(object sender, EventArgs e)
{
if (IsPostBack)
{
if (drpUniversity.SelectedItem.Value.ToString() == "Others".ToString())
{
int rowcount = mytable.Rows.Count;
HtmlTableRow row = new HtmlTableRow();
row.ID = "tbl_row" + (rowcount + 1);
HtmlTableCell cell1 = new HtmlTableCell();
cell1.ID = "tbl_cell1" + (rowcount + 1);
HtmlTableCell cell2 = new HtmlTableCell();
cell2.ID = "tbl_cell2" + (rowcount + 1);
cell1.Attributes["class"] = "contact";
cell2.Attributes["class"] = "contact";
TextBox tb = new TextBox();
tb.ID = "tbQty" + (rowcount + 1);
tb.Width = 276;
Label lblotherUniver = new Label();
lblotherUniver.ID = "lbluniversity";
lblotherUniver.Text = "University Name";
cell2.Controls.Add(lblotherUniver);
cell1.Controls.Add(tb);
row.Cells.Add(cell2);
row.Cells.Add(cell1);
mytable.Rows.Insert(8, row);
mytable.DataBind();
}
}
}
But, the problem is when its creating a TextBox
and a Lable
then the other DropDownList
named drpFaculty's and drpSupervisor's SelectedIndexChange
events are not working.
In my drpSupervisor SelectedIndexChange event have This Code:
protected void drpSupervisor_SelectedIndexChanged(object sender, EventArgs e)
{
txtSupervisorEmail.Text = drpSupervisor.SelectedItem.Value.ToString();
txtSupervisorEmail.Visible = true;
}
This is not working after Select Others from drpUniversity.
Otherwise this is working.
Please help me to solve this problem.