Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,
I have a Gridview , that bind all the respective value(day, debit, credit, balance) from the table.
I just want to add a footer row that can have some of all debit & credit amount.
Gridview:Autogeneratecolumns is true;

so tell me what should be the approprite code to do it.

ASP.NET
<asp:GridView ID="gdview" runat="server"  CssClass="p"
              style="top: -13px; left: 2px; position: relative; height: 964px; width: 703px" 
              AllowPaging="True" GridLines="None" 
              onpageindexchanged="gdview_PageIndexChanged" 
              onpageindexchanging="gdview_PageIndexChanging" ShowFooter="True" 
              Font-Names="Courier New" Font-Size="Small" PageSize="50" 
                    onrowdatabound="gdview_RowDataBound">
         
              
         
          <pagersettings pagebuttoncount="4" mode="NextPrevious" nextpagetext="Next">
                    PreviousPageText="Pre" />
          <pagerstyle font-underline="True" forecolor="Black" horizontalalign="Justify" />
   
  <columns>
  <asp:TemplateField>
  <footertemplate>
<asp:Label ID="lbl_fdebit" runat="server" Text='<%#"$"+Eval("Debit") %>'>
  </footertemplate>
  
  </columns></pagersettings>


C#
private void binddata()
    {
       
        string st = "D";
        con = new SqlConnection(constr);
        cmd = new SqlCommand("SELECT  datepart(" + st + ", date) as day1, CheckNO, Narration, COD, Debit, Credit, Balance FROM  IOB_Stmt1 WHERE (Date between '" +  Session["fordate"].ToString() + "' and '" + Session["todate"].ToString() + "')", con);
        da = new SqlDataAdapter(cmd);
        ds = new DataSet();
        da.Fill(ds, "Emp");
        //return ds.Tables[0];
        gdview.DataSource = ds;
        gdview.DataBind();
        gdview.Visible = true;

        DataTable dt = ds.Tables["Emp"];
        Session["datatable"] = dt;
        //gridbind();
        //gdv.DataSource = ds;
        //gdv.DataBind();
 }
Posted
Updated 16-Nov-11 4:13am
v3
Comments
[no name] 16-Nov-11 10:13am    
When will people learn to format the code they post?
Mehdi Gholam 16-Nov-11 10:35am    
When we are old and gray. :)

"Panel" concept will help to solve this problem.
 
Share this answer
 
Hi Vimdream,

Go through the following article.

Hope it helps

http://msdn.microsoft.com/en-us/library/bb310552.aspx[^]
 
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