Link to home
Start Free TrialLog in
Avatar of terencepires
terencepires

asked on

Gridview doesn't show up !

Hello all,

i am trying to create a gridview from a datatable. The datatable is filled up with data, no worries on this side. But the gridview doesn't show up...

Any ideas why ?

Cheers,

Terence
protected void Page_Load(object sender, EventArgs e)
    {
        DataTable test = readExcel();
        
        GridView toto = new GridView();

        toto.DataSource = test;
        toto.AutoGenerateColumns = true;
        toto.Visible = true;
        toto.DataBind();
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of rajvja
rajvja
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of terencepires
terencepires

ASKER

yes there is

the data is taken from an excel file, using an oledbconnection object, which is not available in the list of standard connection types

what do you mean by "you need to specify the location" ?
ok done
just created a div and added it to it's control collection

thanks !
You are creating an instance of GridView but is not added to the controls on the page.

You can add the GridView on the aspx page and seperately bind it in code-behind without any issue.
If no data is found, It will not be displayed.
No need to set explicit visibility also.

.aspx:
<asp:GridView ID="toto" runat="server" AutoGenerateColumns="true" >
        </asp:GridView>
   
.cs

protected void Page_Load(object sender, EventArgs e)
    {
        DataTable test = readExcel();
     
        toto.DataSource = test;
        toto.DataBind();
    }
sorry... my bad....