|
create a list selectlist from DataSet. or convert a dataset into a selectlist item to populate a dropdownlist
List list = new List { };
foreach(DataRow oDataRow in oCountry.DataSetCountry.Tables[0].Rows)
{
SelectListItem oSelectListItem = new SelectListItem { Value = (String)oDataRow["CountryCode"],Text = (String)oDataRow["CountryName"]};
list.Add(oSelectListItem);
}
ViewData["DDLCountry"] = list;
|