一、 加入事件GridView RowCommand
二、给btn加属性 CommandArgument,CommandName
后台
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
if (e.CommandName=="showAndHide")
{
Label lbl = GridView1.Rows[index].FindControl("LabIsPay") as Label;
Button btn = GridView1.Rows[index].FindControl("ButIsPay") as Button;
lbl.Visible = true;
btn.Visible = false;
}
}
Button ButIsPay = (Button)NianDaiGridView.Rows[e.RowIndex].FindControl("ButIsPay");
ButIsPay.Visiable = false
同理:Label