This is a migrated thread and some comments may be shown as answers.

[Solved] Equivalent of DBNULL when using RadGrid

2 Answers 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RB
Top achievements
Rank 1
RB asked on 09 Jul 2014, 09:32 PM
I have worked with GridView earlier and wanted to know what is the equivalent of DBNull.Value when using Radgrid.
For instance, with gridview I could do the following check:  

System.Data.DataRowView View = (System.Data.DataRowView)e.Row.DataItem;
var isSuppProduct = (DBNull.Value != View[this._ProdTable.ItemIdColumn.ColumnName]);

But how to do this comparision with Radgrid?

  protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = (GridDataItem)e.Item;
                var isSuppProduct = (DBNull.Value != dataItem["SupplementalOriginalPriceDealEntityProductItemId"]);//which is not correct
            }
      }

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Jul 2014, 04:42 AM
Hi,

You can check for DBNull using " ". Please try the following code snippet.

C#:
if(dataItem["ColumnUniqueName"].Text != " ")
{
// Your Code
}

Thanks,
Princy
0
RB
Top achievements
Rank 1
answered on 10 Jul 2014, 03:14 PM
Yes.Thats what I did but thought it was tacky!
Tags
Grid
Asked by
RB
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
RB
Top achievements
Rank 1
Share this question
or