how to get first column value of each row in Gridview

Posted by Vanchi050585 under ASP.NET on 6/15/2010 | Views : 25930 | Status : [Member] | Replies : 2
hi everybody,

pls let me know how to get first column value of each row in Gridview?

i am writing like this:

int Total=0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
Total += = Convert.ToInt32(GridView1.Rows[i].Cells[0].Text); //it does not have column value
}

pls tell what mistake in my code.

sorry,
i have bind the value in first column like below
<%# Eval("Paymount")%>


Thanks

Thanks
tvn



Responses

Posted by: Lukkiram on: 6/15/2010 [Member] Starter

Up
0
Down
Getting data from a selected row in a gridview.

protected void GridView1_SelectedIndexChanged(object sender,
> EventArgs e)
> {
> // Get the currently selected row using the SelectedRow
> property.
> GridViewRow row = GridView1.SelectedRow;
>
> //This row doesn't put anything in the text box (code copied
> from MSDN)
> TextBox2.Text = row.Cells[2].Text;
>
> //This row (when not commented out and line above commented
> out) puts the row index in the text box
> //TextBox2.Text = GridView1.SelectedRow.RowIndex.ToString();
> }

Thanks&Regards,
Lukkiram

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Syedshakeer on: 6/15/2010 [Member] Starter

Up
0
Down
Hi,
look the below code
int Total=0;

for (int i = 0; i < GridView1.Rows.Count; i++)
{
Toatal=Total+ GridView1.Rows[i].Cells[0].Text ;
}



Syed Shakeer Hussain

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response