In my from I hae one drop-down box. If I will select one entry from the drop-down then in another drop-down the data will be retrive automatically on basis of the selected value of previous drop-down box. How is it possible? Somewhat I have idea is I have to pass one query to fetch the data from the database. but where should I have to write that query and how is it possible?
Please let me know.
Loading

Soft CornerPosted Mar 7, 2011, 3:02 AM
check this rar
Krishna already given you the solution .. let me give you complete code of example..
Sahil JaniPosted Mar 10, 2011, 12:17 AM
Suthish NairPosted Mar 7, 2011, 2:48 PM
chiranjita nayakPosted Mar 7, 2011, 2:55 AM
First On pageload event bind 1st dropdown then
set AutoPostBack properties of DropDownList1 become true and on onselectedindexchanged just bind second dropdown.
IN ASPX page:
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
on cs page
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList1.DataSource = " your code";
DropDownList1.DataBind();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.DataSource = " your code";
DropDownList2.DataBind();
}
I hope this will help you !!!!
Krishna GaradPosted Mar 7, 2011, 2:37 AM
In page load Bind first DropdownList
Page_Load
{
// Bind Dropdownlist1
}
Next Go to dropdownlist1 in Design view select it and hit F4 it will show property window here set AutoPostBack property to true close window now Double click on DropDownList1 it will generate SelectedIndexChangedEvent like
DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//Now here fire your query to fill DropDownList2
}
Sahil JaniPosted Mar 7, 2011, 1:41 AM
Soft CornerPosted Mar 7, 2011, 1:08 AM
your dropDown Problem solved or not here?
Vijay YadavPosted Mar 7, 2011, 12:44 AM
I have not attached any file here, i have just given you suggestion for writing the code.
Sahil JaniPosted Mar 7, 2011, 12:27 AM
Vijay YadavPosted Mar 7, 2011, 12:25 AM
On selectedindex changed event of dropdown1, you can wite the code to get data for dropdown2.
I hope this will work!!!!