I have a button out of GridView. I want to get the row index on that button click. How to get it?

Posted by See29ram under ASP.NET on 12/6/2011 | Points: 10 | Views : 12062 | Status : [Member] | Replies : 6
I used this in button click event

GridViewRow row = ((Button)sender).Parent.Parent as GridViewRow;

but it's not working.




Responses

Posted by: Bees7000 on: 12/6/2011 [Member] Starter | Points: 25

Up
0
Down
hi
you can use this to get rowindex

Response.Write(GridView1.SelectedIndex.ToString());


Marwan

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

Posted by: Arefin on: 12/6/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Just see the below link, you will get your answer:
http://weblogs.asp.net/gurusarkar/archive/2010/09/22/get-gridview-rowindex-upon-button-click.aspx

If you face any problem, plz let me inform.


Thanks,
Arefin

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

Posted by: See29ram on: 12/6/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Arefin,
thanku so much for your link.....
But the thing is i have placed my button outside of the gridview.....i need to fire button click event where i have to find current row inside gridview.....
im waiting for ur reply......

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

Posted by: Blessyjees on: 12/7/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

You couldn't get the curerntrow from outside of the grid view. But you can read all rows from the outside of the grid.
Can you tell your requirment of this. May be anyone can give any other solution.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

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

Posted by: Prabhakar on: 12/7/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi See29ram ...


if u placed button outside to gridview ..i think it's not possible to fetch current row . . u retrieve current row on select index changed event . .
try this . .

protected void  gv1_SelectedIndexChanged(object sender, EventArgs e)

{
GridViewRow row = gv1.SelectedRow;
ssno = Convert.ToInt32(row.Cells[2].Text);
}


Best Regard's
Prabhakar

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

Posted by: See29ram on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
the thing is i kept a button(templatefield) inside the gridview...using that button i could popup dropdownlist using jquery...in that popup i kept a submit button..using that submit button i need to find out that current row...and have to store the datas from gridview to database.....this what i need to do.....help me if u have solutions....

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

Login to post response