Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want sum column in datagridview interview in textbox
pleass help my Thanks
Posted

1 solution

Not sure of if you are talking of Windows app or Web app.

In either case, you need to traverse row-wise data present in grid. get the column values and add them up.

Ex in web:
C#
//Something similar to this
int total = 0;
protected void DataGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{
     Textbox tbx = (TextBox)e.Row.FindControl("column2textbox");
     if (tbx != null)
     {
         // you got tbx.Text  value here. Do any calculation desired.
         // total += Convert.ToInt32(tbx.Text) ;
     }
}
// After DataBind() event of grid, use this total value to show anywhere.
 
Share this answer
 
Comments
vinod dev 24-May-10 3:50am    
Reason for my vote of 1
super
BillW33 21-Sep-10 13:36pm    
"Super"?? Does vinod dev realize that 1 is bad and 5 is good?

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