Problem with selection based dropdown buttons?

Posted by Rajeshk under Sql Server on 12/29/2012 | Points: 10 | Views : 763 | Status : [Member] | Replies : 5
hi all,
in my application i have 3 dropdown buttons(department,staff,designation) by the selectiion of dept drop down button i need to set the staff drop down button same like by the selection of staff drop down button ,designation has to produce,i know how to do manully for this but i need to know by giving datasource to each dropdown in in sqlserver (so that it has to filter the items based on selection)

Thanks&Regards
rajeshkommireddy@gmail.com



Responses

Posted by: Guna27 on: 12/29/2012 [Member] Starter | Points: 25

Up
0
Down
set the autopostback as true to all the DropDownList, then include the selection changed event for DDL.
Based on the selection you made, fetch the data and assign it to next DDL as datasource.

Guna..............

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sinisreedhar on: 12/29/2012 [Member] Starter | Points: 25

Up
0
Down
protected void department_SelectedIndexChanged(object sender, EventArgs e)
{
//Wrire the code for filling staff
}
protected void staff_SelectedIndexChanged(object sender, EventArgs e)
{
//Wrire the code for filling designation
}

Ready to accept challenges at any time.....

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 12/29/2012 [Member] Starter | Points: 25

Up
0
Down
have a look on my code....in this when i select state from dropdown1, the dropdown2 displays the corresponding project names that is going on that selected state...
mydb.myconnection();

SqlCommand cmd = new SqlCommand("select ID, project_name from project_report where state='"+DropDownList1.SelectedItem .Text +"'", mydb .sqlcon );
SqlDataAdapter adp = new SqlDataAdapter(cmd );
DataSet ds = new DataSet();
adp.Fill(ds );
DropDownList2.DataSource = ds;
DropDownList2.DataTextField = "project_name";
DropDownList2.DataValueField = "ID";
DropDownList2.DataBind();


Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 12/29/2012 [Member] Starter | Points: 25

Up
0
Down
put my code under dropdown1 selected event

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 12/29/2012 [Member] Starter | Points: 25

Up
0
Down
have u done???

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response