Asp.net 填充网格视图';使用多个查询删除列

Asp.net 填充网格视图';使用多个查询删除列,asp.net,gridview,Asp.net,Gridview,我想用query1填充网格的第一列和第二列,用query2填充第三列,用query3填充第四列 代码在网格的RowDataBound事件中运行,但不起作用: protected void gvInner_RowDataBound(object sender, GridViewRowEventArgs e) { gvInner.Visible = true; if (e.Row.RowType == DataControlRowType.DataRow) {

我想用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();
        }
    }
}
更改这些行

Label iso = (Label)gvInner.FindControl("lbl_iso");
Label description = (Label)gvInner.FindControl("lbl_desp");


它怎么不起作用?请提供更多详细信息(即错误代码等)。
Label iso = (Label)e.Row.FindControl("lbl_iso");
Label description = (Label)e.Row.FindControl("lbl_desp");