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
<asp:GridView ID=”GridView1″ DataKeyNames=”Id” ShowFooter=”true”
DataSourceID=”SqlDataSource1″ onrowdatabound=”GridView1_RowDataBound” >
<asp:BoundField DataField=”Id” HeaderText=”Id” InsertVisible=”False”
ReadOnly=”True” SortExpression=”Id” />
<asp:BoundField DataField=”EmpName” HeaderText=”EmpName”
<asp:BoundField DataField=”EmpSal” HeaderText=”EmpSal”
<asp:SqlDataSource ID=”SqlDataSource1″ runat=”server”
ConnectionString=”<%$ ConnectionStrings:ConnectionString %>”
SelectCommand=”SELECT * FROM [tblEmp]”></asp:SqlDataSource>
Step3: Click on “RowDataBound” event of gridview like this
Step 4: Write the code like This
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.Text);
else if (e.Row.RowType == DataControlRowType.Footer)
e.Row.Cells.Text = “Total Rs”;
//e.Row.Cells.Text = sum.ToString(“c”, new CultureInfo(“hi-IN”));
e.Row.Cells.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!
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.
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..