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

Display blank, if there is no date

1 Answer 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Atchut
Top achievements
Rank 1
Atchut asked on 20 Jul 2012, 05:44 PM
Hello,

Here is my bound column in Telerik Grid. I want to display blank, if there is no date for that value in datafield.

Right now, it is displayin Jan 01, 0001 as default value. How can I do that.

Is there any setting in bound html. ?

      <telerik:GridBoundColumn DataField="ExpirationDate" UniqueName="ExpirationDate" HeaderText="Expiration Date" DataFormatString="{0:MMM d, yyyy}" ></telerik:GridBoundColumn>

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 23 Jul 2012, 04:38 AM
Hi Atchut,

Please try the following code snippet to display blank, if there is no date.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem ditem = (GridDataItem)e.Item;
        if (ditem["ExpirationDate"].Text == "Jan 1, 1900")
        {
            ditem["ExpirationDate"].Text = "";
        }
    }
}

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