博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

<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);

        }     
    }