我写我的代码下按钮,如下错误的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