GRIDVIEW ERROR STRANGE PROBLEM

Posted by Su_ma_2011 under Regular Expressions on 1/28/2011 | Points: 10 | Views : 1373 | Status : [Member] | Replies : 6
The error i am getting for the below code is:
Cannot implicitly convert System.Web.UI.WebControls.GridViewRow to System.Web.UI.WebControls.GridView

The code is as below:

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridView row = GridView1.SelectedRow;
strv1 = row.Cells[1].Text;

}
Am i missing out any namespace... PLZZZ HELP

Suchitra


Responses

Posted by: Prabhakar on: 1/28/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi suchitra

i think u mistake with write space in between ( GridView Row )

tha's the write code

GridViewRow row = gvarticle.SelectedRow;
lblano.Text = row.Cells[0].Text;


if it's working .. so click . as on Mark As Answer
Thanks & Re grad's
Prabhakar

Best Regard's
Prabhakar

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

Posted by: Krkc on: 1/28/2011 [Member] Starter | Points: 25

Up
0
Down
Suchitra, the problem is Typecasting. You cannot type cast GridViewRow as GridView control.

-Ravi

Thanks,
Ravi

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

Posted by: Karthikanbarasan on: 1/28/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

You need to use like this

GridViewRow row = GridView1.SelectedRow

Thanks
Karthik
www.f5Debug.net

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

Posted by: Su_ma_2011 on: 1/28/2011 [Member] Starter | Points: 25

Up
0
Down
NONE OF THE ABOVE SOLUTIONS HELPED:(

Suchitra

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

Posted by: Karthikanbarasan on: 1/28/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
still u are getting the same error... if yes pls paste the complete code we will look into that

Thanks
Karthik
www.f5Debug.net

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

Posted by: Su_ma_2011 on: 1/28/2011 [Member] Starter | Points: 25

Up
0
Down
Mr Karthik,

The code is already in the question i asked

Suchitra

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

Login to post response