1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Fill field in RadGrid dependent on value

Fill field in RadGrid dependent on value

4 posts, 0 answered
  1. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    15 Aug 2008
    Link to this post
    hello Telerik team

    I have a RadGrid that is connected to a SQLDataSource for instance 'select field1 from table1'.
    Dependent on the value of field1 I want to show specific info in the RadGrid:
    - if field1 is empty I want to show the text 'Not available' in the RadGrid.
    - if field1 not is empty the value must be shown.

    Can this be solved in the aspx file with telerik:GridTemplateColumn (with Eval) or must this be solved programmatically?

    Kind regards
    Luc
  2. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    18 Aug 2008
    Link to this post
    Hello Luc Baeten,

    You need to solve this programmatically. However, it can be done with the Eval method. The following code inside of the TemplateColumn should achieve the goal:
    <%# (String.IsNullOrEmpty(Eval("Field1").ToString())) ? "Not available" : Eval("Field1") %> 

    This is simply an if condition in one line. What it does is first it checks the condition (is Field1 empty) - if so it outputs "Not available", if not it outputs the value of the field.

    I hope you'll find this information helpful. Let us know if there is anything else we can do for you.

    Regards,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    18 Aug 2008
    Link to this post
    Hello Ivan

    Thank you for this info. This is what I was looking for.

    Regards
    Luc
  4. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    18 Aug 2008
    Link to this post
    Hello Luc Baeten,

    Glad to be able to help. Let us know if there is anything else we can do for you.

    Kind regards,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
4 posts, 0 answered