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

[Solved] GridHyperLinkColumn with empty DataTextField

1 Answer 169 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yaroslav
Top achievements
Rank 1
Yaroslav asked on 13 Mar 2008, 05:14 PM
Hi,

If the value of property, which is defined in DataTextField property of the GridHyperLinkColumn, is empty or null, then the grid cell is rendered in a way  like this:

<td><a href="MyPage.aspx?MyItemId=5"></a></td>

This cause problems in IE, because there is no border of such a cell there.
All I can do is to use ItemDataBound handler to redefine rendering rules:

protected void Grid_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;
        MyObject myObject = item.DataItem as MyObject;
        TableCell cell;
        if (string.IsNullOrEmpty(myObject.MyProperty))
        {
            cell = item["MyProperty"];
            cell.Controls.Clear();
            cell.Controls.Add(new LiteralControl("&nbsp;"));
        }
    }
}

After that my cell is rendered in this way:

<td>&nbsp;</td>

And after that, that's OK with IE :)

Is it possible not to perform this routine?

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 17 Mar 2008, 02:58 PM
Hi Yaroslav,

Unfortunately this is an issue with IE and borders for empty table cells which can be reproduced with plain html table as well. Hence to bypass this discrepancy you need to inject &nbsp; in these cells as you already found out.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Yaroslav
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or