<asp:TemplateField HeaderText = "Quantity Delivered" SortExpression="TotalQDelivered"> <ItemTemplate> <asp:Label ID="lblQuantityDelivered" runat="server" Text='<%#Eval("TotalQDelivered") %>' /> </ItemTemplate> </asp:TemplateField>
if (e.Row.RowType == DataControlRowType.DataRow) { int TotalQuantity= 0; TotalQuantity += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "TotalQDelivered")); } if (e.Row.RowType == DataControlRowType.Footer) { Label lblamount = (Label)e.Row.FindControl("lblTotal"); lblamount.text = TotalQuantity.ToString(); } // I get this Error Object cannot be cast from DBNull to other types. // I must Say that some of the rows are null in the Gridview,
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)