查找在GridView/Repeater中单击Button的行

use*_*119 1 asp.net gridview repeater

我有约束力了Repeater.在Repeatera Button和a 中的每一行(是正确的单词?)HiddenField.如何确定HiddenField基于单击哪个Button 的值?

Button OnClick事件背后的代码:

protected void btnButton1_Click(object sender, EventArgs e)
{
    Button btnButton1 = (Button)sender;        
    // how do i get this row's HiddenField Value?
}
Run Code Online (Sandbox Code Playgroud)

编辑:CommandArgumentPleun 的建议有效,但我仍有问题.我需要RepeaterButton属于的行中找到行(?),因为TextBox每行中还有一个,我需要它的值.所以理想情况下我想得到那一行并去FindControl("TextBox1")等等.抱歉,应该在我最初的问题中说明

Ple*_*eun 5

我喜欢做的是向按钮添加一个CommandArgument.在这段代码中它的图像按钮但想法是一样的.所以也不需要额外的隐藏领域.

<asp:ImageButton ID="btnMail" ImageUrl="~/imgnew/prof/sendlink.png" 
CommandArgument='<%# Eval("id")%>'
Run Code Online (Sandbox Code Playgroud)

并在_Click事件中做

 string id = ((ImageButton)sender).CommandArgument;
Run Code Online (Sandbox Code Playgroud)

更新:

如果您需要所有数据,则需要使用其他事件.转发器中的数据以Item in的形式提供

RepeaterCommandEventArgs 
Run Code Online (Sandbox Code Playgroud)

在Command事件中(RepeaterCommandEventArgs)

处理Command事件请参阅此示例 http://www.asp.net/data-access/tutorials/custom-buttons-in-the-datalist-and-repeater-cshttp://msdn.microsoft.com/ EN-US /库/ system.web.ui.webcontrols.repeatercommandeventargs.aspx