Guest User

Guest User

  • Tech Writer
  • 515
  • 42.7k

Regarding binding Cascaded DropdownList

Aug 29 2018 8:29 PM
Hello,
 
I am using OrmLite technology in my MVC code. I need help to bind selected Cascaded DropdownLists (Country, State, City) for a logged in user which is saved on Signup Form.
 
Below is my code (this code binds only Country):
 
var countrystring = "SELECT Id, CountryName FROM CountryMaster where Id ='" + countryid + "'";
DataSet ds = new DataSet();
List<string> li = new List<string>();
DataTable dt = new DataTable();
dt = objdal.MyMethod(countrystring.ToString());
List<SelectListItem> list = new List<SelectListItem>();
foreach (DataRow row in dt.Rows)
{
list.Add(new SelectListItem { Text = Convert.ToString(row.ItemArray[1]), Value = Convert.ToString(row.ItemArray[0])});
}
ViewBag.country = list;
 
Here it binds Country based on CountryId, but another CountryNames is not getting bound.
 
Thanks in advance.

Answers (3)