在线等 gridview 动态生成BoundField错误
public void GetMxMessage()
{
string tName = Request.QueryString["name"];
int key = Convert.ToInt32(Request.QueryString["action"]);
DataSet ds = DBConn.SqlFactory.GetTableName(tName);
DataSet dsValue = DBConn.SqlFactory.GetMx(tName,key);
if (ds.Tables[0].Rows.Count > 0)
{
this.GridView1.DataSource = dsValue;
this.GridView1.AutoGenerateColumns = false;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string liName = ds.Tables[0].Rows[0]["name"].ToString();
BoundField bdf1 = new BoundField();
bdf1.HeaderText = liName;
if (dsValue.Tables[0].Rows.Count > 0)
bdf1.DataField = dsValue.Tables[0].Rows[0]["'" + liName + "'"].ToString();
this.GridView1.Controls.Add(bdf1);
}
this.GridView1.DataBind();
}
}
错误 1 与“System.Web.UI.ControlCollection.Add(System.Web.UI.Control)”最匹配的重载方法具有一些无效参数 F:\tzgl\tzgl\right.aspx.cs 67 17 F:\tzgl\
错误 2 参数“1”: 无法从“System.Web.UI.WebControls.BoundField”转换为“System.Web.UI.Control” F:\tzgl\tzgl\right.aspx.cs 67 45 F:\tzgl\