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

Telerik RadGrid And Filtering _Replaced Null Values_ Issue

1 Answer 234 Views
Grid
This is a migrated thread and some comments may be shown as answers.
SilverLight
Top achievements
Rank 1
SilverLight asked on 31 May 2012, 09:37 AM
i have a BooundColumn in my telerik RadGrid like below :  

<telerik:GridBoundColumn DataField="Status" FilterControlAltText="Filter Status column"
    HeaderText="Status" SortExpression="Status" UniqueName="Status"
    FilterImageToolTip="Filter">
    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridBoundColumn>

Status Column in my sql server 2008 database can accept null values and RadGrid shows them with an empty string.
so i replaced those Empty Strings with the codes below ?  

protected void grdSMS_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        if (item["Status"].Text == " ")
        {
            item["Status"].ForeColor = Color.Red;
            item["Status"].Text = "Empty";
        }
    }
}

now my problem is i can not filter Empty Columns.  
how can i fix this issue? 

Note:
In the codes upper if (item["Status"].Text == " ") Correction Isif (item["Status"].Text == "&nbsp;")

thanks in advance

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 31 May 2012, 11:40 AM
Hi,

One suggestion is to replace the null values of the status field in the DataBase with a string to perform the filtering.

C#:
protected void grdSMS_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        if (item["Status"].Text == " ")
        {
            item["Status"].ForeColor = Color.Red;
            item["Status"].Text = "Empty";
            // code to update the status field in the Database with string ("Empty").
 
        }
    }
}

Thanks,
Princy.
Tags
Grid
Asked by
SilverLight
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or