前台的模板列中通过红色字体 将当前行号绑定给 CommandArgument
<asp:TemplateField HeaderText="操作"ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Middle">
<ItemTemplate>
<asp:Button ID="btnRejCorp"Text="驳回" runat="server"CommandName="CorpDateReject" CommandArgument='<%#Container.DataItemIndex %>'/>
</ItemTemplate>
</asp:TemplateField>
后台
protected voidgridCorpReport_RowCommand(object sender, GridViewCommandEventArgse)
{
if (e.CommandName == "CorpDateReject")
{
int LB = Int32.Parse(e.CommandArgument.ToString());
varlbl =(HyperLink)gridCorpReport.Rows[LB].FindControl("lblcorptip");
string corpid = gridCorpReport.Rows[LB].Cells[0].Text;
}
}