Error : Object reference not set to an instance of an object.
<asp:TemplateField HeaderText="Salary" ItemStyle-Width="65%"> <ItemTemplate> <asp:TextBox ID="txtSal" runat="server" ForeColor="Blue" Width="75%" Text='<%# Eval("Sal") %>' ReadOnly="true" MaxLength="7"></asp:TextBox> </ItemTemplate> <FooterTemplate> <asp:Label ID="LBLTotal" runat="server" ForeColor="Green"></asp:Label> </FooterTemplate> <ItemStyle HorizontalAlign="Center"/> </asp:TemplateField>
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim sum As Integer = 0 For index As Integer = 0 To GridView1.Rows.Count - 1 If CStr(Me.GridView1.Rows(index).Cells(12).Text) <> "" Then sum += Convert.ToInt32(Me.GridView1.Rows(index).Cells(12).Text) End If Dim Tot As Label = DirectCast(GridView1.FindControl("LBLTotal"), Label) Tot.Text = sum Next End If End Sub
If e.Row.RowType = DataControlRowType.Footer Then //your code here End If
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)