Hi
Here are some few step to perform this task
Step1: Take one gridview and Sqldatasource control in default.aspx page
step2: Configure the SqldataSource control and gridview control like this
<div>
<asp:GridView ID=”GridView1″ DataKeyNames=”Id” ShowFooter=”true”
runat=”server” AutoGenerateColumns=”False”
DataSourceID=”SqlDataSource1″ onrowdatabound=”GridView1_RowDataBound” >
<Columns>
<asp:BoundField DataField=”Id” HeaderText=”Id” InsertVisible=”False”
ReadOnly=”True” SortExpression=”Id” />
<asp:BoundField DataField=”EmpName” HeaderText=”EmpName”
SortExpression=”EmpName” />
<asp:BoundField DataField=”EmpSal” HeaderText=”EmpSal”
SortExpression=”EmpSal” /></Columns>
</asp:GridView><br />
<asp:SqlDataSource ID=”SqlDataSource1″ runat=”server”
ConnectionString=”<%$ ConnectionStrings:ConnectionString %>”
SelectCommand=”SELECT * FROM [tblEmp]”></asp:SqlDataSource></div>
Step3: Click on “RowDataBound” event of gridview like this
Step 4: Write the code like This
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;public partial class _Default : System.Web.UI.Page
{
private decimal sum = 0;
protected void Page_Load(object sender, EventArgs e)
{}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
sum = sum + Convert.ToDecimal(e.Row.Cells[2].Text);
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Text = “Total Rs”;
//e.Row.Cells[2].Text = sum.ToString(“c”, new CultureInfo(“hi-IN”));
e.Row.Cells[2].Text = sum.ToString();
e.Row.Font.Bold = true;
}}
}
Step 5: Compile the code .You will Output like this
I hope this will help to some one.
wonderful publish, very informative. I’m wondering why the other specialists of this sector don’t understand this.
You should continue your writing. I am confident,
you have a huge readers’ base already!
Hi
Thanks for sending kind and motivative feedback. I will continue my writing.
What’s Happening i’m new to this, I stumbled upon this I
have discovered It positively useful and it has aided
me out loads. I hope to give a contribution & help other users like its aided me.
Great job.
Thank you.
I don’t know whether it’s just me or if perhaps everyone else encountering issues with your blog.
It seems like some of the written text on your posts are running off the
screen. Can somebody else please comment and let
me know if this is happening to them too? This may be a problem with my internet browser because I’ve had this happen before. Kudos
Thanks a lot for sharing this with all of us you actually know what
you are speaking approximately! Bookmarked. Please also visit my web
site =). We can have a hyperlink alternate
arrangement among us
Very good post. I am facing a few of these issues as well..