这个需要通过gridview绑定的结果集获取。我曾经这样获取 public DataRow dr;
SqlConnection sqlCon = dbCon.conDB();
SqlDataAdapter da = new SqlDataAdapter(strSql, sqlCon);
DataSet ds = new DataSet();
da.Fill(ds, "work");
dr = ds.Tables["work"].Rows[0];然后再在HTML页面获取。由于我不是太习惯在前台写代码所以都是通过按钮跳转 protected void grdXWS_RowCommand(object sender, GridViewCommandEventArgs e) { if(e.CommandName.Equals("info"))//自己多命名的相应按钮的commandname { int iPage = this.grdXWS.PageIndex;
int iIndex = Convert.ToInt32(e.CommandArgument);
int theIndex = iIndex - (iPage * grdXWS.PageSize);
string sID = grdXWS.DataKeys[theIndex]["XW_ID"].ToString();
//注意对gridview设置主键 Response.Redirect("showXW.aspx?id=" + sID);
} }