Hi,
In the classic ultraWebGrid control, the following code (in code behind, Runtime, VB.NET language) changes the column header and width
UltraWebGrid.Columns(0).Header.Caption = "Column Name1"
UltraWebGrid.Columns(0).Width = New Unit("32px")
How to do the above change for the Webdatagrid in runtime?
Thanks, Karthik
Hello Karthik ,
Thank you for posting in our forum.
The WebDataGrid also has a columns collection. You can get a specific column by index in the same way :grid.Columns(0)
To set the header text you can get the header and set the text property : grid.Columns(0).Header.Text=”Some text”
The column also has a Width property you can set in the same manner : grid.Columns(0).Width=New Unit(“32px”)
Is perhaps your columns collection AutoGenerated? If that’s the case then your columns collection would be empty.
If that’s the case you could either set the AutoGenerateColumns property of the grid to false , create the columns runtime and add them to the columns collection or if you need to leave them autogenerated get a reference to them from the items in the rows for example: grid.Rows(0).Item(0).Column.
Let me know if you have any questions or concerns.
Best Regards,
Maya Kirova
Developer Support Engineer II
Infragistics, Inc.
http://es.infragistics.com/support
Thanks for the response.
The grid rows/columns are attached using datatable, so can't set the AutoGenerateColumns to False.
Anyway, I've used the following code in the 'WebDataGrid1.InitializeRow' server side event.
objGridRecord = e.Row
objGridRecord.Items(0).Column.Width = New Unit("32px")
objGridRecord.Items(0).Text = "ColumnHeader1"
I had same issue that had been resolved using "InitializeRow" event. But I am facing challenge when there is no data then this event doesn't execute.
And if I try to set width from other source then last column of grid gets truncated.
please help me on this..