Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying for girdview where each row total is to be displayed


< gridview>

<asp:TemplateField>
<itemtemplate>
getprice(DataBinder.Eval(Container.DataItem, unit_price))
<itemtemplate>



<asp:TemplateField>
<itemtemplate>
getqty(DataBinder.Eval(Container.DataItem, unit_qty))





XML
<asp:TemplateField>
<ItemTemplate>
lable_id=total
</ItemTemplate>
</asp:TemplateField>





unit_price unit_qty total
100 2 200


i am unable to get total as 200

please help how to rowbound each row and get the output total
Posted
Comments
Zafar Sultan 2-Jan-13 7:37am    
Post your complete aspx code for GridView.

Hi,

Add an empty column in the grid,

after that on row bound event use the following code,

C#
protected void gridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[10].Text = Convert.ToInt32(e.Row.Cells[8].Text) * Convert.ToInt32(e.Row.Cells[9].Text);
}
}</pre>
 
Share this answer
 
Comments
mani.kishore.asp.net 2-Jan-13 6:49am    
i tried but it says

{"Input string was not in a correct format."}
Hi,

Please take help from this link:

http://www.aspdotnet-suresh.com/2011/02/how-to-display-sum-of-columns-total-in.html[^]

may be it ll help you if not please let me know.

Thanks.
 
Share this answer
 
v2
Comments
Prasad_Kulkarni 3-Jan-13 2:00am    
Link formatted.
nehas1jan 3-Jan-13 2:05am    
??

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