Repeater 控件获取单击行索引值
时间:2011-02-17 来源:共谱一曲
<asp:Repeater ID="rptUserList" runat="server">
<ItemTemplate>
<tr align="center">
<td>
<%=RowIndex++ %>
</td>
<td>
<asp:HiddenField ID="HideID" runat="server" Value='<%#Eval("PKID") %>' />
<asp:LinkButton ID="lbtnPwdReset" runat="server" OnClick="lbtnPwdReset_Click" class="lbtnBottom">[密码重置]</asp:LinkButton>
</td>
<td>
<img alt="修改" src="http://www.cnblogs.com/Images/38.gif" />
</td>
<td>
<img src="http://www.cnblogs.com/Images/16.gif" alt="删除" />
</td>
</tr>
</ItemTemplate>
//后台代码
//[重置密码]单击事件
protected void lbtnPwdReset_Click(object sender, EventArgs e)
{
LinkButton bt = sender as LinkButton;
RepeaterItem rptItem = bt.Parent as RepeaterItem;
HiddenField pkid = rptItem.FindControl("HideID") as HiddenField;
ClientScript.RegisterStartupScript(GetType(),"HaiLan","<script>alert('"+pkid.Value+"');</script>");
}