问题描述
在我的aspx页面(来自母版页)中,我包括了如下的动态gridview-
SqlDataSource数据=新的SqlDataSource("System.Data.Odbc",_connection.ConnectionString,Cmd);
GridView MainGridView =新的GridView();
BoundField bfield1 =新的BoundField();
bfield1.HeaderText =主题";
bfield1.DataField ="TopicsCount";
MainGridView.Columns.Add(bfield1);
BoundField bfield2 =新的BoundField();
bfield2.HeaderText =帖子";
bfield2.DataField ="PostsCount";
MainGridView.Columns.Add(bfield2);
MainGridView.AutoGenerateColumns = false;
MainGridView.Caption =< div class = \" main-head \>< h2 class = \" hn \>" + i +</span>//h2</div>";
MainGridView.DataSource =数据;
MainGridView.DataBind();
这里的TopicsCount和PostsCount来自我没有在这里包含的查询字符串.SqlDataSource和query没有问题.当我运行该站点时,我看不到带有数据的GridView !.请给我实际的解决方案.
in my aspx page(derived from a masterpage) i included a dynamic gridview as follows-
SqlDataSource Data = new SqlDataSource("System.Data.Odbc", _connection.ConnectionString, Cmd);
GridView MainGridView = new GridView();
BoundField bfield1 = new BoundField();
bfield1.HeaderText = "Topics";
bfield1.DataField = "TopicsCount";
MainGridView.Columns.Add(bfield1);
BoundField bfield2 = new BoundField();
bfield2.HeaderText = "Posts";
bfield2.DataField = "PostsCount";
MainGridView.Columns.Add(bfield2);
MainGridView.AutoGenerateColumns = false;
MainGridView.Caption = " <div class=\"main-head\"><h2 class=\"hn\">" + i + "</span></h2></div>";
MainGridView.DataSource = Data;
MainGridView.DataBind();
here the TopicsCount and PostsCount comes from the query string i did not include here.there is no problem with SqlDataSource and query.when i run the site i do not see GridView with data!.please give me practical solution.
推荐答案
这篇关于具有绑定字段的动态GridView在我的页面中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!