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

GridLine disappear when a cell is empty

8 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Myriam
Top achievements
Rank 1
Myriam asked on 13 Nov 2008, 08:54 PM
Hello
I have a Grid with many gridboundcolumn. When one of the cell doesn,t contain data, it taking off the line around the cell...how can I work around this problem?
Thanks in advance

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 14 Nov 2008, 05:34 AM
Hi Myriam,

Try the following work arround.

CS:
protected void RadGrid2_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridDataItem dataItem in RadGrid2.Items)  
        {  
            foreach (GridColumn col in RadGrid2.Columns)  
            {  
                if (dataItem[col.UniqueName].Text == string.Empty)  
                    dataItem[col.UniqueName].Text += " ";    
   
            }  
        }  
    }  


Thanks
Shinu.
0
Daniel
Telerik team
answered on 14 Nov 2008, 08:05 AM
Hello Myriam,

I suggest you another approach:
<telerik:GridBoundColumn  
DataField="CategoryID" 
DataType="System.Int32"  
EmptyDataText="&amp;nbsp;"  
HeaderText ... 

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Myriam
Top achievements
Rank 1
answered on 14 Nov 2008, 01:33 PM

Hello
I'm REALLY REALLY sorry, but I just saw that my problem is only with templatecolumns....
And it doesn't have a EmptyDataText property....

Does it have another property who does the same thing for a templatecolumn...

Thanks in advance

and sorry for that mistake, my fault

0
Accepted
Daniel
Telerik team
answered on 14 Nov 2008, 01:44 PM
Hello Myriam,

Just add &nbsp; tag in your ItemTemplate/EditItemTemplate.

<ItemTemplate> 
&nbsp;<asp:TextBox ID="TextBox1" ... /> 
</ItemTemplate> 

Kind regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jason Lee
Top achievements
Rank 1
answered on 01 Dec 2009, 04:07 AM
Dear Daniel,

I have try EmptyDataText function.
However, it only works when data is null.
The datatype is empty string ( String.Empty ), it won't work.
so, is it possible to support when data equal to empty string, emptydatatext function will work ?

thank you

0
Jason Lee
Top achievements
Rank 1
answered on 02 Dec 2009, 02:42 PM
In other words, when the data type is string and data is null or empty, it shows "&nbsp;
0
Daniel
Telerik team
answered on 03 Dec 2009, 06:21 PM
Hello Jason,

You could add the non-breaking space tags manually on ItemDataBound as shown below:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        foreach (TableCell cell in e.Item.Cells)
        {
            if (String.IsNullOrEmpty(cell.Text.Trim())) cell.Text = " ";
        }
    }
}

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jason Lee
Top achievements
Rank 1
answered on 04 Dec 2009, 01:47 AM
Dear Daniel,

Yes, I know it.
If the function would built in RadGrid, that will be great.
Tags
Grid
Asked by
Myriam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Daniel
Telerik team
Myriam
Top achievements
Rank 1
Jason Lee
Top achievements
Rank 1
Share this question
or