我聲明在此之後,這是錯誤我得到不包含定義認定中
protected void Page_Load(object sender, EventArgs e)
{
List<String> LabelTextList = new List<String>();
dr = cmd.ExecuteReader();
while (dr.Read())
{
LabelTextList.add(dr[0].ToString());
}
}
錯誤1「MasterPage_Profile」不包含關於「LabelTextList」和沒有擴展方法的定義「LabelTextList」接受類型「MasterPage_Profile」的第一個參數可以發現(?是否缺少using指令或程序集引用)
[更新]現在它說:
「System.Collections.Generic.List」不包含「添加」的定義並且沒有擴展方法'add'接受類型'System.Collections.Generic.List'的第一個參數可能被發現(你是否缺少使用指令或程序集引用?)
開始列表 LabelTextList = new List ();應該是列表 labelTextList =新列表();和this.LabelTextList.add(dr [0] .ToString());應該是labelTextList.add(dr [0] .ToString()); –
,除非你已經聲明瞭一個名爲LabelTextList的字段,那麼你不會使用this關鍵字來獲取它。你已經在方法級別範圍內,所以這不是必需的,不適用 – owen79
@PaulZahra我改變了它。名稱'labelTextList'在當前上下文中不存在。 – user3021598