Click here to Skip to main content
15,916,463 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

Add this grid in your page


Page.Controls.Add(MainGridView);
 
Share this answer
 
no not works.also i tried masterPageformname.Controls.Add(MainGridView);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900