Find the below code ...it will help u achieve ur task
for (int i=0;i<gridview1.rows.count;i++)>
{
int totalmasrks=0;
for(int j=1;j<gridview1.columns.count-1;j++)>
{
totalmarks += Convert.ToInt32(GridView1.Rows[i].Cells[j].Text)
}
GridView1.Rows[i].Cells[4].Text= tottalmarks.toString();
}
hav great day
Enjoy :)
plz vote and click accept ans if it helps.