我寫我的代碼下按鈕,如下錯誤的GridView
string actkey = string.Empty;
foreach (GridViewRow row in GridView1.Rows)
{
//Label lbInvoice = (Label)row.FindControl("lblInvoice");
string strInvoice = GridView1.DataKeys[row.RowIndex].Values["lblInvoice"].ToString();
objinvoice.Invoice = strInvoice;
RadioButton rdn = (RadioButton)row.FindControl("rdnRenew");
if (rdn.Checked)
{
actkey = oCustomerDetails.CreateRandom(20);
objinvoice.activationcode = actkey;
objinvoice.editInvoice(actkey, strInvoice);
}
}
但我在這個
string strInvoice = GridView1.DataKeys[row.RowIndex].Values["lblInvoice"].ToString();
得到一個錯誤,這有什麼錯在我所寫的
我宣佈我的項目模板如下
<ItemTemplate>
<asp:Label ID="lblInvoice" runat="server" Text='<%# Eval("invoceNo") %>'></asp:Label>
</ItemTemplate>
你遇到了什麼錯誤? – 2010-08-14 08:33:05
處理了空引用異常 未將對象引用設置爲對象 – Dotnet 2010-08-14 08:37:31
因此,集合中沒有鍵「lblInvoice」的元素。 – 2010-08-14 08:38:55