在线等 gridview 动态生成BoundField错误

huyan1986 huyan1986 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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\
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
huyan1986
.NET社区 62,272 成员 668,968 内容