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 CornerRank #1,221 · 1.5K reputationPosted Mar 6, 2011, 10:02 PM EST
check this rar
Krishna already given you the solution .. let me give you complete code of example..
Vijay YadavRank #1,637 · 943 reputationPosted Mar 6, 2011, 7:25 PM EST
On selectedindex changed event of dropdown1, you can wite the code to get data for dropdown2.
I hope this will work!!!!
Sahil Jani196 reputationPosted Mar 6, 2011, 7:27 PM EST
Vijay YadavRank #1,637 · 943 reputationPosted Mar 6, 2011, 7:44 PM EST
I have not attached any file here, i have just given you suggestion for writing the code.
Soft CornerRank #1,221 · 1.5K reputationPosted Mar 6, 2011, 8:08 PM EST
your dropDown Problem solved or not here?
Sahil Jani196 reputationPosted Mar 6, 2011, 8:41 PM EST
Krishna GaradRank #191 · 12.8K reputationPosted Mar 6, 2011, 9:37 PM EST
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
}
chiranjita nayak2 reputationPosted Mar 6, 2011, 9:55 PM EST
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 !!!!
Suthish NairRank #92 · 22.8K reputationPosted Mar 7, 2011, 9:48 AM EST
Sahil Jani196 reputationPosted Mar 9, 2011, 7:17 PM EST