I need to control access to individual cells of a WebDataGrid based on a external datatable Used to build the grid column and rows. The grid is being used to place orders based on Product availablitiy. Basically controlled by two values (one drives columns with first column in grid containing the value that will control the rows sort of like x and y coordinates where first col is the Y values and the columns are the x values) I have to build the grid based on a product selection and not all X, Y combinations are available.
The light bluegreeen cells are available, but the black cell are not available. I would like to be able to disable editing the the black cells and either shade the cells black ro remove all formating so that they are hidden.
I have a css where I set the background color to black:
.pwrsGridCellNotAvail {background-color: Black}
and in the initializeRow event I have set the style to: e.Row.Items(colInd).CssClass &= " pwrsGridCellNotAvail" but the grid does not take my css. I have tried doing the same in a sub called after I bind the datasource to the datatable for the grid. I have done this before in another application using the UltraWebGrid, but the WebDataGrid does not seem to be as flexible, but could be missing something. Please help. When do I set the WebDataGrid individual cells to readonly and shade them black or hide them (which is what I really want)
e.Row.Items(colInd).CssClass &= " pwrsGridCellNotAvail"
but the grid does not take my css. I have tried doing the same in a sub called after I bind the datasource to the datatable for the grid.
I have done this before in another application using the UltraWebGrid, but the WebDataGrid does not seem to be as flexible, but could be missing something. Please help.
When do I set the WebDataGrid individual cells to readonly and shade them black or hide them (which is what I really want)
Hi Hoyadev,
It has been a while since your post, however in case you still need assistance I would be glad to help.
Regarding making only some cells in a column non-editable:
You could handle the EnteringEditMode event and based on your logic, cancel the event which will effectively make the desired cells uneditable.
In order to style individual WebDataGrid cells, your CSS class should be defined as follows
<style type="text/css">TBODY > TR > TD.YourClassName{ background-color:Blue;}</style>
Then you should be able to apply the styling by using for instance:
e.Row.Items[3].CssClass = "YourClassName";
Please let me know if you need further assistance.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://www.infragistics.com/support
Peter,
This was helpful, but how would you change this code to make it alter the styling for an entire row?
I wanted the fore color of a row to be Red if Column(7) was greater than 48.
<style type="text/css">
TBODY > TR > TD.RedRow{color:Red;} </
</
style>
This does not work: If CInt(e.Row.Items.GetValue(7).ToString) > 0 Then e.Row.CssClass = "RedRow" End If This will color the 3rd column red If CInt(e.Row.Items.GetValue(7).ToString) > 0 Then e.Row.Items(3).CssClass = "RedRow" End If
This does not work:
If CInt(e.Row.Items.GetValue(7).ToString) > 0 Then
e.Row.CssClass = "RedRow"
End If
This will color the 3rd column red
e.Row.Items(3).CssClass =
"RedRow"
I find the WebDataGrid and documentation difficult to work with and the documentation to be limited.