Cannot apply indexing with [] to an expression of type 'int'

Posted by Lohith G S under C# on 8/3/2012 | Points: 10 | Views : 4528 | Status : [Member] | Replies : 1
Hi everyone,
I have a problem with gridview as i'm new to web application and expecting a solution to the below code. It goes like this,

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
GridView row = GridView1.SelectedRow;
txtLastName.Text = GridView1.SelectedRow.RowIndex[0].ToString();
txtFirstName.Text = GridView1.SelectedRow.RowIndex[1].ToString();
txtEmailAddress.Text = GridView1.SelectedRow.RowIndex[2].ToString();
txtPhoneNumber.Text = GridView1.SelectedRow.RowIndex[3].ToString();
txtDOB.Text = GridView1.SelectedRow.RowIndex[4].ToString();

how shall i proceed. I'm getting error it reads like this Cannot apply indexing with [] to an expression of type 'int'

Thanks in advance


Posted by: Rajkatie on: 8/3/2012 [Member] [MVP] Gold | Points: 25

Kindly refer following link

Rajesh Patel
R.P.A Developer | Developer Trainer | Clean Code Evangelist

Lohith G S, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response