tags:

views:

557

answers:

1

I am building a grid dynamically and putting buttons in one of the columns. When I click a button, I want to know what row of my grid it's in. How can I find this?

+4  A: 

In the Click event handler for the button you say:

int row;
Button btn = sender as Button;
if (btn != null)
{
    row = Grid.GetRow(btn); // And you have the row number...
}
else
{
    // A nasty error occurred...
}
Boyan