我有检索数据表的方法,我正在尝试加载到组合框并且它工作正常但我无法设置Datatextfield和DataValuefield,当我尝试它显示错误指示不包含定义。
这是检索数据表
的方法的代码片段DataTable dtTable = new DataTable();
using (SqlConnection sqlConnection = new SqlConnection(cs))
{
using (SqlCommand sqlCommand = new SqlCommand("SELECT Id,CampaignName FROM CampaignsTable", sqlConnection))
{
sqlConnection.Open();
using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
{
dtTable.Load(sqlDataReader);
sqlDataReader.Close();
}
}
}
return dtTable;
加载到组合框的代码片段下面
drpDownProfiles.DataSource = rank.RetrieveProjectNames();
drpDownProfiles.DataTextField = "Not Working";
drpDownProfiles.DataValueField = "Not Working";
答案 0 :(得分:0)
这两个属性:
drpDownProfiles.DataTextField = "Not Working";
drpDownProfiles.DataValueField = "Not Working";
应设置为:
drpDownProfiles.DataTextField = "CampaignName";
drpDownProfiles.DataValueField = "Id";