DataBinding:“System.String”不包含名为“TotalType”的属性。
筛选不重复类型作为数据源:
public List<string> GetTotallType()
{
SqlConnection conn =
new SqlConnection("data source=localhost;initial catalog=Supermarket;uid=sa;pwd=123456;");
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "Select TotalType from GoodsTypeList";
SqlDataReader reader = cmd.ExecuteReader();
List<string> list = new List<string>();
while (reader.Read())
{
bool isTrue = false;
for (int i = 0; i < list.Count; i++)
{
if (reader["TotalType"].ToString() == list[i])
{
isTrue = true;
break;
}
}
if (isTrue == false)
{
list.Add(reader["TotalType"].ToString());
}
}
return list;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)