you may do it in ASPX (HTML gridview tag by adding
autogeneratecolumns ="false" in the in the gridview tag >
for reference
http://authors.aspalliance
Main Topics
Browse All TopicsGreetings all,
I have placed a DataGridView on myPage. It displays with 3 columns - Column0, Column1, Column3; each displaying "abc" in the cells (and messing up my aligning of my control!).
My incoming data will always be of the same format. Through the columns collection I was able to create my own columns along with choice of titles (changing the HeaderText field).
How do I get rid of the Column0, Column1and Column2? And when I view in browser I don't see my grid - is this because there is no data? Can I display the grid regardless of whether or not there is data or even if the grid is not connected to a datasource?
In advance, thanks!
allanmark
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
you may do it in ASPX (HTML gridview tag by adding
autogeneratecolumns ="false" in the in the gridview tag >
for reference
http://authors.aspalliance
Fantastic!! So simple when you know how (or in my case when someone else knows how!!)
If I could come back to this part: "Can I display the grid regardless of whether or not there is data ? (both at runtime and when I "View In Browser"to see how my page really looks).
... Have a bit more to ask, if you don't mind ... have upped the points to cover that (not sure if this is acceptable or if I should close this one and open another).
(1) Having done as you suggested, I now have just my headings. If I click on the control and drag to
size to my specifications, I am left with what appears to be an enlarged heading row and several
really small rows underneath (with the overall size being what I want). Does this mean that my
heading row has been resized or is it just the way it displays?
(2) Do you know of a good tutorial / link to a video -- I think I'll be using this grid a lot and could efinitely do with such.
Many thanks.
allanmark
few free videos you may find here
http://www.learnvisualstud
for sites .. there are sites having alot of articles about GRIDVIEW
http://www.gridviewguy.com
http://www.gridviewgirl.co
alot of good working examples for all .net platform (i have given link specific to asp.net you may brows this site for all other too)
Thanks
http://samples.gotdotnet.c
Sorry for only ocming back now -- there's just so much stuff in the sites you posted (hoping to do some more surfing later tonight.
As per my previous post, I tried to find answers to these questions, using the sites that you provided - no luck.
1. Can I display the grid regardless of whether or not there is data ? (both at runtime and when I
"View In Browser"to see how my page really looks).
2. DGW: Having done as you suggested, I now have just my headings. If I click on the control and
drag to size to my specifications, I am left with what appears to be an enlarged heading row and
several really small rows underneath (with the overall size being what I want). Does this mean that
my heading row has been resized or is it just the way it displays?
Can you suggest anything?
Thanks
allanmark
1- what meant by displaying grid without data?
if you have have set headers of columns that means it will display headers and 5 rows in design mode (when you are working on forms in editor ..VS)
but if you run in browser then you will see only headers ..
2-when you drag to make it wide .. definitly available columns will expand to fill the new width of gridview
if you want to make each column of a specific size then
IN ASPX you may add itemStyle of you can set it in GridView designer too
like this
<asp:BoundField DataField="Salary" DataFormatString={0:d} HeaderText="Salary" >
<ItemStyle Width="400px" />
</asp:BoundField>
Thanks for your patience!
1. Displaying grid without data -- Sorry, poorly explained on my part. What I should have set was that I
ran the browser to see how my page would look and the grid is not displayed at all - no headings,
nothing!
This led me to the 2nd part which was wondering if, at runtime, there was no data if the grid would
still be displayed --- I guess your reply "but if you run in browser then you will see only headers "
answers that - I should at least seethe headers!
2. Sorry - again, poorly explained on my part. What I should have said was that I drag the bottom of the
grid down, to fill up the available page space. The 5 rows (which I now understand - thankyou!!)
increased only fractionally in size, whilst the heading row expanded seriously [now, in design
mode, I have a header row of 60mm and the five data rows of 4mm -- approximate estimations
based on screen appearance]. If this is normal (from what you wrote, I think that it is) - OK - I just
want to make sure that I haven't made another "Idiot User Error".
Once again, thanks for everything.
Sorry for ambigous reply.
here is detail for what you asked.
if you set Header text for colums and dont provide DataField on design time then you would be able to see on header and few rows at design time and nothing would be shown if you see it in browser.
to show in browser you must provide some sample datasource. at least there should be one Row of data to make a gridview to show in browser.
to fill the page space .. by draging .it does not make sense.. because if your datasorce has only one row.. how it would fill the page???? making cells too big??
hence you must set default pageSize of GRV to fill the page. GRV will expand to bottm side depending on the number of rows per page.
thanks
Business Accounts
Answer for Membership
by: needo_jeePosted on 2007-12-12 at 06:58:13ID: 20457352
Select GridView which you have placed .. it will give you option go to property pages (a small arrowhead at top right corner of gridview appears)
Click on Edit Column and in the next dialogue you will see a checkbox at left bottom corner .. uncheck that (Enable auto generate columns)