for ( int i = 0 ; i <= GridView1.Rows.Count - 1 ; i ++ ) { DataRowView dv = ds.Tables[0].DefaultView[i]; lbl = (Label)GridView1.Rows[i].FindControl("Label1"); if (lbl.Text.Trim() == "1") { lb = (LinkButton)GridView1.Rows[i].FindControl("LinkButton1"); lb.Text ="已审核"; } else if (lbl.Text.Trim()== "-1") { lb = (LinkButton)GridView1.Rows[i].FindControl("LinkButton1"); lb.Text = "未审核"; } /**//* else if(Convert.ToString(dv["state"])=="0") { lb = (LinkButton)GridView1.Rows[i].FindControl("LinkButton1"); lb.Text = "过期"; }*/ } LinkButton lb = (LinkButton)sender; DataControlFieldCell dcf = (DataControlFieldCell)lb.Parent; GridViewRow gvr = (GridViewRow)dcf.Parent; GridView1.SelectedIndex = gvr.RowIndex; string picadid = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString(); // 获取当前行的关键值 转载于:https://www.cnblogs.com/qyfan82/archive/2007/07/29/835449.html