Sachin Mitna

Sachin Mitna

  • NA
  • 20
  • 1.4k

How to grand total in Dynamic Gridview when column was auto generated

Oct 6 2020 1:34 AM
i want grand total on footer textbox plz suggest me best code.......
 
<asp:GridView ID="GridView1" OnRowCreated="GridView1_RowCreated" OnRowDataBound="GridView1_RowDataBound" runat="server" AutoGenerateColumns="False" Width="480px" Height="169px" ShowFooter="True" CellPadding="4" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField HeaderText="SrNO">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ProductName">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownlist1_SelectedIndexChanged2" AutoPostBack="true" ></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quntity">
<ItemTemplate>
<asp:TextBox ID="TextBox3" OnTextChanged="TextBox4_TextChanged" AutoPostBack="true" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Rate">
<ItemTemplate>
<asp:TextBox ID="TextBox4" OnTextChanged="TextBox4_TextChanged" AutoPostBack="true" runat="server" ></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lbl1" Text="GrandTotal" runat="server"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TotalAmount">
<ItemTemplate>
<asp:TextBox ID="TextBox5" OnTextChanged="TextBox4_TextChanged" AutoPostBack="true" runat="server"></asp:TextBox>
</ItemTemplate>
<FooterStyle Horizontal />
<FooterTemplate>
<asp:TextBox ID="TextBox6" runat="server" AutoPostBack="true" OnTextChanged="TextBox6_TextChanged" ></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<FooterStyle Horizontal />
<FooterTemplate>
<asp:Button ID="add" runat="server" Text="Add Row" OnClick="add_Click" />
</FooterTemplate>
</asp:TemplateField>

Answers (4)