Why does my GridView no display?

here's some code.  The Gridview2 does not display. Can please anyone tell me what is missing from this code?

        GridView1.AutoGenerateColumns = False

        Dim dt As New DataTable

        Dim col0 As New DataColumn
        Dim col1 As New DataColumn
        Dim col2 As New DataColumn
        Dim col3 As New DataColumn
        Dim col4 As New DataColumn

        Dim row0 As DataRow
        Dim row1 As DataRow


        col0.ColumnName = "Cost Center Name"
        col0.DataType = System.Type.GetType("System.String")
        dt.Columns.Add(col0)

        col1.ColumnName = "Total Budget"
        col1.DataType = System.Type.GetType("System.String")
        dt.Columns.Add(col1)

        col2.ColumnName = "Used Budget"
        col2.DataType = System.Type.GetType("System.String")
        dt.Columns.Add(col2)

        col3.ColumnName = "Remaining Budget"
        col3.DataType = System.Type.GetType("System.String")
        dt.Columns.Add(col3)

        col4.ColumnName = "Cost Center ID"
        col4.DataType = System.Type.GetType("System.Int32")
        dt.Columns.Add(col4)


        row0 = dt.NewRow()
        row0(0) = "asasas"
        dt.Rows.Add(row0)

        row1 = dt.NewRow()
        row1(1) = "44444"

        dt.Rows.Add(row1)

        GridView2.AutoGenerateColumns = False
        GridView2.Caption = "66666666"
        GridView2.DataSource = dt
        GridView2.Visible = True
LVL 1
HLRosenbergerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Is it in ASP.NET? Try adding a GridView2.DataBind()
0
Ady FootSharePoint ConsultantCommented:
This gridview control you're using - is it a third party control?

Regards,

Ady
0
Ady FootSharePoint ConsultantCommented:
Ah if it's ASP.net you can disregard my post above.  
0
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

HLRosenbergerAuthor Commented:
No.  the one that comes with Visual Studio.  I'm also using another instance of it in Bound mode, and that works fine.  
0
HLRosenbergerAuthor Commented:
I'm coding in VB.  I'm am creating an ASP.NET WEB page.
0
CodeCruiserCommented:
You mean its a WinForms app? What version of VS?


  GridView2.AutoGenerateColumns = False

Set it to true? Or do you have columns defind in designer?
0
CodeCruiserCommented:
Did you add

GridView2.DataBind()

at the end?
0
HLRosenbergerAuthor Commented:
I want to totally design it in code.  It show 3 column in the Studio, but I think they are there just for the IDE, because the grid designer window does hot show any columns.
0
CodeCruiserCommented:
Change following code


        GridView2.AutoGenerateColumns = False
        GridView2.Caption = "66666666"
        GridView2.DataSource = dt
        GridView2.Visible = True

to


        GridView2.AutoGenerateColumns = True
        GridView2.Caption = "66666666"
        GridView2.DataSource = dt
        GridView2.DateBind()
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HLRosenbergerAuthor Commented:
This line did the trick.

GridView2.AutoGenerateColumns = True

I thought AutoGenerateColumns was only used to Auto Generate columns created in the designer.

Thanks!
0
HLRosenbergerAuthor Commented:
Thanks!
0
CodeCruiserCommented:
Glad its sorted :-)
Autogenerate means that generate the grid columns automatically for the columns in the datatable.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.