|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datagrid colums name ??Dear all,
I have a datagrid erver control which is bind to a dataset. How to display as column name custom text instead of database fields name ? Ex : Started At instead of START_TIME_COL thnaks regards serge You can go into the DataGrid's Property Builder (right-click on
DataGrid -> Property Builder) and accomplish this. Under the Columns section, uncheck "Create columns automatically at run time" and then add each Bound Column, if they are not already there. Under each Bound Column's properties, you can change the HeaderText property to whatever you want. Just make sure to leave the DataField property to the field name in the database. Thanks for your reply
I need to bind datset to datagrid dynamically , so grid column name as well, so I do not want to you the propertie builder from the IDE. I rather prefer to code it If I do that, is there a particular event that I can play with which occurs just before the grid gets dispay and allows me to change column text and datbound filed ? thnaks Show quote "joshuac***@gmail.com" wrote: > You can go into the DataGrid's Property Builder (right-click on > DataGrid -> Property Builder) and accomplish this. Under the Columns > section, uncheck "Create columns automatically at run time" and then > add each Bound Column, if they are not already there. Under each Bound > Column's properties, you can change the HeaderText property to whatever > you want. Just make sure to leave the DataField property to the field > name in the database. > > I don't blame you on not wanting to use the IDE, I prefer not to as
well. It might be easier to come up with a solution if I knew a little bit more about what the application is doing, for instance, when you are collecting the data that determines the column names. One suggestion would be to use a DataTable instead of a DataSet. Is there a fixed number of columns and how are you determining what the columns are to be named? The DataSet does have the following property that maybe you could use: oDataSet.Tables(0).Columns(0).ColumnName You could traverse through the DataSet and change the ColumnName based on the index, before you bind it to the DataGrid. |
|||||||||||||||||||||||