Groups | Blog | Home
all groups > asp.net datagrid control > october 2005 >

asp.net datagrid control : Create Columns at run time


Scott M.
10/1/2005 12:00:00 AM
If the columns are going to be made automatically at run-time, then you
can't modify them at design-time.

If you are going to want to configure aspects of the columns yourself, then
you'll need to un-check "Create columns automatically at run time." and
manually add columns yourself.

I suggest adding Bound columns first and configuring each to be bound to the
appropriate data field from your data source. After they are created and
working, I would then click the link in the bottom of the Property Builder
to "Convert to Template Column", so that you can get even more control over
the configuration of the columns.



[quoted text, click to view]

Tina
10/1/2005 5:46:05 PM
if you place a datagrid on a form and then, in Property builder, check the
box saying Create Columns at run time. An then do a SQL Select into a
datatable, and then bind the datatable to the grid, the grid displays
correctly. BUT, the columns array is empty. The grid displays just fine.
There are cells and rows but no columns.

I want to make some of the columns non visible but I can't because there are
no columns.

Why is this?
Thanks,
Tina

Tina
10/2/2005 3:16:29 PM
I Can't do what you say because my program is a SQLTable Update Utility. I
don't know what the columns will be at design time.

I'm "Creating the columns at run time" via a databind which does indeed
create the grid correctly but the Columns array is nothing i.e.
Datagrid1.columns(0) is out of bounds.

It seems the columns array should be there. the Headertext is even there
which is an attribute of the columns in the array.

What is really odd is related to another thread you replied to where my
datagrid was empty in a subsequent button click event. It was because I had
the Create columns checkbox checked!!!!!!!! When I unchecked it, my grid
had all of its rows and data in the button event. I think thats a bug in
the grid componnet.
T

[quoted text, click to view]

AddThis Social Bookmark Button