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
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();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok done
just created a div and added it to it's control collection
thanks !
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();
}
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....
ASKER
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" ?