我想将数据库中的两列绑定到下拉列表中。这是我的代码:
SqlConnection con=new SqlConnection(CommonRefference.Constr());
string query = "Select Id,Name+' ('+Distribution_name+') 'as Name1 from BR_supervisor ";
SqlCommand cmd = new SqlCommand(query,con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
DropDownList3.DataSource = query;
DropDownList3.DataTextField = "name1";
DropDownList3.DataValueField = "Id";
DropDownList3.DataBind();
}
con.Close();
但它给出了以下错误
DataBinding:“System.Char”不包含名为“name1”的属性
怎么做?任何帮助我的人都非常感谢