I have written the following code to databind a gridview control on an asp website. When I step through the code the dataview shows that it had rows and columns the databind method executes but the gridview is not visible on my webpage.
if (!IsPostBack)
{
DataSet ds = GetData();
if (ds.Tables.Count > 0)
{
DataView dv = new DataView(ds.Tables[0]);
GridView1.DataSource = dv;
GridView1.Visible = true;
GridView1.DataBind();
}
}
Loading
Raghavendra UPosted Jul 13, 2010, 3:42 AM
Amit ChoudharyPosted Jul 13, 2010, 3:23 AM
if you want auto generated columns then check if AutoGeneratedColumn property of your gridview set to "true" if you want custom columns then set this porperty to false... and define your custom template or bound field... in your gridview design...
also check if visible property or style="display:none" should not be there.
and last check if you grid view is added to the page or not. if you are using dynamic gridview generate from code behind like:
GridView gv=new GridView();
then add this after you bind statement to the page.
this.page.form.Controls.Add(gv);
Please mark "Do you like this post" if it helps you.