What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 62272 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET > Populate more than one datas in second ddllist by selcting single data in f ...
Shailesh21235

Populate more than one datas in second ddllist by selcting single data in first ddlist frm datatable

Replies: 3 | Posted by: Shailesh21235 on 6/4/2012 | Category: ASP.NET Forums | Views: 208 | Status: [Member] | Points: 10  


CountryTable
DataRow drCountryRow1 = dtCountryTable.NewRow();
drCountryRow1["CountryId"] = "1";
drCountryRow1["CountryName"] = "India";
dtCountryTable.Rows.Add(drCountryRow1);

DataRow drCountryRow2 = dtCountryTable.NewRow();
drCountryRow2["CountryId"] = "2";
drCountryRow2["CountryName"] = "Usa";
dtCountryTable.Rows.Add(drCountryRow2);

CityTAble
DataRow drCityRow1 = dtCityTable.NewRow();
drCityRow1["CityId"] = "1";
drCityRow1["CityName"] = "Delhi";
dtCityTable.Rows.Add(drCityRow1);

DataRow drCityRow2 = dtCityTable.NewRow();
drCityRow2["CityId"] = "2";
drCityRow2["CityName"] = "Mumbai";
dtCityTable.Rows.Add(drCityRow2);

DataRow drCityRow3 = dtCityTable.NewRow();
drCityRow3["CityId"] = "3";
drCityRow3["CityName"] = "Goa";
dtCityTable.Rows.Add(drCityRow3);

DataRow drCityRow4 = dtCityTable.NewRow();
drCityRow4["CityId"] = "4";
drCityRow4["CityName"] = "NewYork";
dtCityTable.Rows.Add(drCityRow4);

DataRow drCityRow5 = dtCityTable.NewRow();
drCityRow5["CityId"] = "5";
drCityRow5["CityName"] = "Texas";
dtCityTable.Rows.Add(drCityRow5);

DataRow drCityRow6 = dtCityTable.NewRow();
drCityRow6["CityId"] = "5";
drCityRow6["CityName"] = "LasVegas";
dtCityTable.Rows.Add(drCityRow6);

I have added these datas from datatable and they are displayed in dropdownlists....
ddlCountry.DataSource = CreateCountryTable();
ddlCountry.DataTextField = "CountryName";
ddlCountry.DataValueField = "CountryId";
ddlCountry.DataBind();
but when i select one country then their cities should be displayed in second dropdownlist..How to display multiple datas in 2nd ddllist????


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Ashoknalam
Ashoknalam  
Posted on: 6/4/2012 5:16:44 AM
Level: Starter | Status: [Member] | Points: 25

First of all you should have CoutnryID reference in citytable so that
from the first dropdown if you select countryid based on selection id fill the city dropdown.






Ashok Nalam

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

Shailesh21235
Shailesh21235  
Posted on: 6/4/2012 5:27:58 AM
Level: Starter | Status: [Member] | Points: 25

how to add refernece in city datatable???
could you provide me with a sample code???

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

Ajay.Kalol
Ajay.Kalol  
Posted on: 6/4/2012 6:27:27 AM
Level: Starter | Status: [Member] | Points: 25



DataRow drCityRow1 = dtCityTable.NewRow();

drCityRow1["CityId"] = "1";
drCityRow1["CityName"] = "Delhi"
drCityRow1["CountryID"] = "2"; // Add CountryID Column in City table for Relation Between City And Country
dtCountryTable.Rows.Add(drCountryRow2);


When You want City By Country then
Use this :
Dim Drow() As DataRow

Drow = dtCityTable.Select("CountryID = "+ DDLCountry.selectedValue.tostring());


http://ajaypatelfromsanthal.blogspot.in

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

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2013 11:53:05 AM