Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,


I've a dropdownList box where it always selects the 1st index(say a). I couldn't select b,c etc....

Here is my coding .....
C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        select_people.Visible = true;
        int ss = Convert.ToInt32(DropDownList1.SelectedValue);
        // _BindEmployeelistByNetwkID(Convert.ToInt32(ddlNetwkName.SelectedValue));
        DropDownList2.DataSource = objBAL.GetNetWorkDetailslist(Convert.ToInt32(Session["UserId"]), Convert.ToInt32(ss));
        DropDownList2.DataTextField = "EmployeeName";
        DropDownList2.DataValueField = "NetwkID";
            DropDownList2.DataBind();
            DropDownList2.Items.Insert(0, new ListItem("Select", "0"));
    }

    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        display.Visible = true;
        Name.Text = DropDownList2.SelectedItem.Text;

    }


DropDownList2.SelectedItem.Text; is not working properly as I couldn't select other options rather than 1st one. Can anyone guide me ?????
Posted
Updated 8-Oct-13 3:00am
v2
Comments
ZurdoDev 8-Oct-13 9:07am    
Are you databinding ddl1 in PageLoad without checking for IsPostBack?
Sriram Ramachandran 8-Oct-13 9:12am    
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
select_people.Visible = false;

_LoadNetwkHdList();
display.Visible = false;
}
}
Sriram Ramachandran 8-Oct-13 9:12am    
I m checking postBack event
ZurdoDev 8-Oct-13 9:23am    
Are you databinding in _LoadNetwkHdList()?
Sriram Ramachandran 8-Oct-13 9:32am    
s ryanDev ..... i binded in ddl1 ..... My concept is
ddl1 --- Select network ---- cat (working)
ddl2 --- Select people ---- a (works but i couldn't select b,c,d) ...



void _LoadNetwkHdList()
{
DataTable dt = new DataTable();
dt = objBAL.GetNetwkList("SelectNetwork");
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "NetwkName";
DropDownList1.DataValueField = "NetwkID";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, new ListItem("Select", "0"));
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900