المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : how i get data from datatable



C# Programming
01-13-2013, 10:30 PM
let's say i have two columns,one called area and second called city .i want to get all the cities when i choos a Specific area .
i use with datatable and i don't know how to Formulate an sql Query.it's suppose to be like that:
string areaName = DropDownList1.Items[DropDownList1.SelectedIndex].ToString().Trim(); DataRow[] city = dt.Select("city_name where area='"+areaName+"'"); for (int i = 0; i < city.Count(); i++) { DropDownList2.Items.Add(city[i]["city_name"].ToString()); }