NULL Value from SQL Server DB becomes " " when evaluating its cell in RadGrid

bpsygsoo  于 12个月前  发布在  SQL Server
关注(0)|答案(1)|浏览(115)

I have a grid being populated by SQL data. In my dataBound method I have a numerical condition that evaluates the text of particular cells, for example: if myCell.Text <90

It is possible for the cell to have NULL values, so I want to check before running these conditions to ensure that the cell is not null. However, the actual text in the cell is evaluated as "nbsp;" (removed the & so it will appear in this post). I don't want to hardcode something like NOT myCell.Text.Contains("nbsp") because that just feels sloppy and problematic.

If TypeOf e.Item Is GridDataItem Then
    Dim dataItem As GridDataItem = e.Item
    Dim myCell As TableCell = dataItem("Status")
    If Not String.IsNullOrWhiteSpace(myCell.Text) Then

This is my current code and obviously the string " " passes this condition.

How do I properly check this value? Is there a different property I can evaluate?

e0bqpujr

e0bqpujr1#

This is a behavior of telerik's radgrid. To change the behavior, set the EmptyDataText field belonging to GridBoundColumn. You can see from the second link below that the default value of a gridBoundColumn is " " which is then converted to &nbsp; by the html encoder.

A like to the documentation for GridBoundColumn is here: Telerik GridBoundColumn

and Telerik GridboundColumn Server Side API Reference

相关问题