我想用query1填充网格的第一列和第二列,用query2填充第三列,用query3填充第四列。
该代码在RowDataBound
网格事件中运行,但它不起作用:
protected void gvInner_RowDataBound(object sender, GridViewRowEventArgs e)
{
gvInner.Visible = true;
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label iso = (Label)gvInner.FindControl("lbl_iso");
Label description = (Label)gvInner.FindControl("lbl_desp");
string str1 = @"SELECT M_MR_ISO_Heads.iso as iso, M_MR_ISO_Heads.description as description
FROM
T_MR_Action_point_Pre_MRM_C INNER JOIN M_MR_ISO_Heads
ON T_MR_Action_point_Pre_MRM_C.iso_heads = M_MR_ISO_Heads.description";
DataTable dt = new DataTable();
dt = SQL_DB.ExecuteDataTable(str1);
if (dt.Rows.Count > 0)
{
iso.Text = dt.Rows[0]["iso"].ToString();
description.Text = dt.Rows[0]["description"].ToString();
}
Label mrmpoints = (Label)gvInner.FindControl("lbl_mrmpoints");
string str2 = @"SELECT T_MR_Action_point_Pre_MRM_C.mrm_no as mrmpoints
FROM
T_MR_Action_point_Pre_MRM_C INNER JOIN M_MR_ISO_Heads
ON T_MR_Action_point_Pre_MRM_C.iso_heads = M_MR_ISO_Heads.description
AND T_MR_Action_point_Pre_MRM_C.iso_heads = M_MR_ISO_Heads.description";
DataTable dt1 = new DataTable();
dt1 = SQL_DB.ExecuteDataTable(str2);
if (dt1.Rows.Count > 0)
{
mrmpoints.Text = dt1.Rows[0]["mrmpoints"].ToString();
}
Label totalpoints = (Label)gvInner.FindControl("lbl_tpoints");
string str3 = @"SELECT Count(T_MR_Action_point_Pre_MRM_C.mrm_no) as totalpoints
FROM
T_MR_Action_point_Pre_MRM_C INNER JOIN M_MR_ISO_Heads
ON T_MR_Action_point_Pre_MRM_C.iso_heads = M_MR_ISO_Heads.description
AND T_MR_Action_point_Pre_MRM_C.iso_heads = M_MR_ISO_Heads.description";
DataTable dt2 = new DataTable();
dt2 = SQL_DB.ExecuteDataTable(str3);
if (dt2.Rows.Count > 0)
{
totalpoints.Text = dt2.Rows[0]["totalpoints"].ToString();
}
}
}