?
Solved

Gridview doesn't show up !

Posted on 2010-01-07
5
Medium Priority
?
280 Views
Last Modified: 2013-11-08
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

0
Comment
Question by:terencepires
  • 2
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
rajvja earned 2000 total points
ID: 26201250
Why are you doing like this? Any reason?
You can code manually in design view to display gridview.

If you want to do this, you need to specify the location where to display the gridview.
0
 
LVL 1

Author Comment

by:terencepires
ID: 26201334
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" ?
0
 
LVL 1

Author Closing Comment

by:terencepires
ID: 31674054
ok done
just created a div and added it to it's control collection

thanks !
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 26201426
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();
    }
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 26201431
sorry... my bad....
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question