LinkButton(或者其他GridView上的想要判斷到底是Click哪個TempPlate按扭)
Posted on 2011-01-31 00:16 ☆Keep★Moving☆ 阅读(494) 评论(0) 编辑 收藏 举报<asp:TemplateField>
<ItemTemplate >
<asp:LinkButton ID="lbtnApprove" runat="server" CommandName="Approve" >Approve</asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbtnReject" runat="server" CommandName="Reject">Reject</asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Application No.">
<ItemTemplate>
<asp:LinkButton ID="lbtnReqNo" runat="server" CommandName="ReqNo" Text='<%# Eval("ReqNo") %>' ></asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="50px" />
<HeaderStyle Wrap="False" />
</asp:TemplateField>
protected void givReqMaster_RowCommand(object sender, GridViewCommandEventArgs e)
{
string l_strReqNo = string.Empty;
if (e.CommandName == "Approve")
{
GridViewRow gvrow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); //获取被点击 的linkButton所在的GridViewRow
int index = gvrow.RowIndex; //获取到行索引RowIndex
//获取当前行的某列值
l_strReqNo = ((LinkButton)givReqMaster.Rows[index].FindControl("lbtnReqNo")).Text.Trim();
UpdateApproveState(l_strReqNo);
}
if (e.CommandName == "Reject")
{
GridViewRow gvrow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); //获uc2取被点击的linkButton所在的GridViewRow
int index = gvrow.RowIndex; //获取到行索引RowIndex
//获取当前行的某列值
l_strReqNo = ((LinkButton)givReqMaster.Rows[index].FindControl("lbtnReqNo")).Text.Trim();
UpdateRejectState(l_strReqNo);
}
if (e.CommandName == "ReqNo")
{
GridViewRow gvrow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); //获uc2取被点击的linkButton所在的GridViewRow
int index = gvrow.RowIndex; //获取到行索引RowIndex
//获取当前行的某列值
l_strReqNo = ((LinkButton)givReqMaster.Rows[index].FindControl("lbtnReqNo")).Text.Trim();
m_strReqNo = l_strReqNo;
GridViewDataBind(l_strReqNo);
}
}