Click here to Skip to main content
15,916,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:GridView runat="server" ID="GridView" Height="233px" Width="1149px" AutoGenerateColumns="False">
                        <Columns>
                            <asp:TemplateField HeaderText="OrderNo" ItemStyle-Width="150">
                                <ItemTemplate>
                                    <%#DataBinder.Eval(Container.DataItem,"OrderNo") %>
                                </ItemTemplate>
                                <ItemStyle Width="150px"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Code" ItemStyle-Width="150">
                                <ItemTemplate>
                                    <%#DataBinder.Eval(Container.DataItem,"Code") %>
                                </ItemTemplate>
                                <ItemStyle Width="150px"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Description" ItemStyle-Width="150">
                                <ItemTemplate>
                                    <%#DataBinder.Eval(Container.DataItem,"Description") %>
                                </ItemTemplate>
                                <ItemStyle Width="150px"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Rate" ItemStyle-Width="150">
                                <ItemTemplate>
                                    <%#DataBinder.Eval(Container.DataItem,"Rate") %>
                                </ItemTemplate>
                                <ItemStyle Width="150px"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Qty" ItemStyle-Width="150">
                                <ItemTemplate>
                                    <%#DataBinder.Eval(Container.DataItem,"Qty") %>
                                </ItemTemplate>
                                <ItemStyle Width="150px"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Total" ItemStyle-Width="150">
                                <ItemTemplate>
                                    <%#DataBinder.Eval(Container.DataItem,"Total") %>
                                </ItemTemplate>
                                <ItemStyle Width="150px"></ItemStyle>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
Posted
Updated 12-Dec-12 20:13pm
v2

 
Share this answer
 
C#
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
  {

      if (e.Row.RowType == DataControlRowType.DataRow)
      {
          TotalPrice += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Total"));
      }
      if (e.Row.RowType == DataControlRowType.Footer)
      {
          TextBox lbltotal = (TextBox)e.Row.FindControl("txttotalprice");
          lbltotal.Text = TotalPrice.ToString();
 
Share this answer
 
This is not a real question. Make your subject a SUBJECT. In your BODY, ask a REAL, CLEAR question. I have no idea what the hell you're talking about, except that you want to put a total somewhere. You want a grand total down the bottom ? You need to add that, probably outside the grid, by summing the values and showing a total separately.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900