I want to fill data into select control like:
abc || 1
bcde || 2
ghiftt || 3
And my code
string str = "";
if (arr != null)
{
return str;
if (arr != null)
{
foreach (MProductInfo info in arr)
{}
string select = "";
if (info.ID == id_select)
select = "selected";
string sName = string.Format("{0}{1}", info.Name.PadRight(70, '\u00A0'), info.Code);
str += "";
}
return str;
Ressult:
abc || 1
bcde || 2
ghife || 3
So how to fix it?
Tien QuangPosted Mar 20, 2015, 5:21 AM
Khargesh RajputPosted Mar 20, 2015, 4:33 AM
and bind
if static data then
DataTable dt =New Datalist();
dt.Columns.Add("FullName", typeof(string), "FirstName + ' ' + LastName");
//add more column in datalist
dropdownlist1.DataSource = dt;
dropdownlist1.DataTextField = "FullName";
dropdownlist1.DataValueField = "ID";
dropdownlist1.DataBind();
if you are binding from database
DataTable dt =New Datalist();
// write code to get data in datalist
//query -- select firstvalue+'-'+secondvalue from table
dropdownlist1.DataSource = dt;
dropdownlist1.DataTextField = "FullName";
dropdownlist1.DataValueField = "ID";
dropdownlist1.DataBind();