When you design columns for UltraWebGrid, one of the settings available to you is Column Type. For example you can set it to Button, and all cells within the column will render and behave as HTML buttons. Other options available such as Check Box or Hyperlink.
But what if you want some of the column cells to be of a different type? For example some of cells aren’t supposed to be links, but plain text instead? The solution is to set Column Type of those cell thru code. Consider following example:
Protected Sub xmyGrid_InitializeRow(ByVal sender As Object, ByVal e As RowEventArgs) Handles xmyGrid.InitializeRow If e.Row.Index > 0 Then e.Row.Cells.FromKey("LINK_CELL).TargetURL = "http://mysite.com?ID=" & e.Row.Cells.FromKey("LINK_ID) Else e.Row.Cells.FromKey("OBJ_NAME").Column.Type = ColumnType.NotSet End If end sub
Above is a handler for UltraWebGrid’s InitializeRow event. It checks if a row is a first row in the grid and if so – sets its column type to “NotSet” effectively removing “Hyperlink” type set at design time. And even though it references type of entire column – the change applies only to the current cell.
do you have any solution: if one of the column cell needs to be a checkbox and other cell in the same column needs to be a button?
@zee I don’t think this is possible via standard grid column types. You may have to resort to custom HTML, e.g. in the example above:
@Yuriy , your solution worked like a charm.
Any idea how to access the button via server side code?
@Tyler button described above in reply to @zee will be a client-side only button. What scenario do you need access button server-side for?