We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridDataBoundGrid and Row Headers

I'm trying to create a databound grid which uses a DataTable as its DataSource (ie. grid.DataSource = myDataTable;). It's a readonly grid BTW, no edits allowed. I'd like to somehow make the grid's row header text be the values of my DataTable's column 0 values. The default behavior seems to be that the grid uses column 0 for a row header and column 1 for the first DataTable column. I've managed to do what I want by hiding the grid's column 1 and in the PrepareViewStyleInfo handler I copy the contents of column 1 to column 0 (the row header) for each row. This seems like a huge hack. Is there a more elegant way of forcing the DataBoundGrid to use my DataTable's first column as the row header values? Any insights appreciated. -Peter

2 Replies

AD Administrator Syncfusion Team September 16, 2003 11:43 AM

Here is something to try. Hide the default row header (col 0). Then set: this.grid.Model.Cols.FrozenCount = 1; This should prevent your column 1 from scrolling and it should just display your column 1 values as a fixed column. If you want the cell to appear like a header cell, then set: this.grid.Binder.InternalColumns[0].StyleInfo.CellType = "Header";

PZ Peter Zaborski September 16, 2003 12:55 PM

Good stuff, that did the trick. Thanks. -Peter

Live Chat Icon For mobile
Up arrow icon