[英]Empty SQL query/Value in Gridview Error
我正在構建一個預訂應用程序,並且正在嘗試修復一個錯誤-我將每個工作站都保留了x天,因此GridView中應顯示0個工作站-但是,當我在日歷中單擊該日期時,程序崩潰並出現此錯誤
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
異常詳細信息:System.NullReferenceException:對象引用未設置為對象的實例。
Source Error:
Line 246: gvAvailable.DataSource = ds.Tables[0];
Line 247: gvAvailable.DataBind();
Line 248: gvAvailable.HeaderRow.Cells[0].Text = "Workstation";
Line 249: gvAvailable.HeaderRow.Cells[1].Text = "Location";
Line 250: }
我測試了選擇該日期時正在執行的查詢,這是一個正確的空查詢,因為預訂了所有電台,但程序崩潰了。 有幫助嗎?
實現了正確的語法以檢查數據集是否為空
ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.