Hi!
i have three tables in database province,division, and subdivision. i entered 4 provinces in province table using asp.net web page1. in next web page2 i used dropdown which get data from province table. for each province in dropdown i entered 6 divisions using textbox and save it in the division table. now in third web page3 i used two dropdowns one for province and one for division and a text box for subdivision entry.
i want that when i select a province from dropdown(e.g punjab) so the dropdown2 show me those divisions that i have entered for that particular province(e.g divsion1,divsion2 for punjab),not all the divisions of all the provinces. how is it possible?????please help me
Loading
Posted May 19, 2011, 2:51 AM
Kindly let me know, if you have any issues.
saifullah khanPosted May 19, 2011, 4:44 AM
Abhimanyu K VatsaPosted May 19, 2011, 4:35 AM
Posted May 19, 2011, 2:26 AM
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/CascadingDropDown/CascadingDropDown.aspx
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/walkthrough/ccdwithdb.aspx
http://www.aspsnippets.com/Articles/Creating-Cascading-DropDownLists-in-ASP.Net.aspx
Abhimanyu K VatsaPosted May 19, 2011, 2:21 AM
for the very first dropdown (province) bind the all database record (you have 4 records). Code would be something like,
DataSourceID="SqlDataSource1"
DataTextField="province"
DataValueField="ID"
Runat="server" AutoPostBack="True" />
SelectCommand="SELECT [ID], [province] FROM [tblprovince]">
Note: remember to mark autopostback enabled.
Job2
Use the code in the code-behind for selectedIndexChenged event of above dropdown.
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//here you have to place the binding data of division drop down
}
i hope this helps
saifullah khanPosted May 19, 2011, 1:57 AM
1. should i bind both of the dropdowns to division table?
2. could you please tell me query?
Abhimanyu K VatsaPosted May 19, 2011, 1:46 AM
Refer this post http://www.vbdotnetheaven.com/UploadFile/abhikumarvatsa/2333/