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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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...
}