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

Problem When No records exists

5 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
VS
Top achievements
Rank 1
VS asked on 28 May 2009, 05:19 AM
Hi,

I have a grid which displays No Records text when no record exists for the grid. It works fine.
But for certain conditions, i dont want to display that message at all. I was successfull in that as well by using as below

Grid1.MasterTableView.NoMasterRecordsText =

"";
But i can see the row line displayed in this case. How can i avoid the row lines being displayed in the grid when that conditions occurs.

Regards

Sujith

 

5 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 28 May 2009, 09:40 AM
Hello Sujith,

I guess you want to hide the extra line for ro record item when there is no records to display in grid. If so you can try out the following code.

CS:
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
{  
    if (e.Item.ItemType == GridItemType.NoRecordsItem)  
    {  
        e.Item.Visible = false;  
    }   

Thanks,
Princy.
0
VS
Top achievements
Rank 1
answered on 28 May 2009, 10:29 PM
Thanks Princy.
That was perfect
0
Karen
Top achievements
Rank 1
answered on 31 May 2009, 02:45 PM
Hello Princy

I have a similar problem, however in my case e.Item.ItemType is never GridItemType.NoRecordsItem  I have debugged and it seems only header footer and pager item types are created when no records to display.
Any suggestions?
0
Shinu
Top achievements
Rank 2
answered on 01 Jun 2009, 05:22 AM
Hi Karen,

Are you checking for the NoRecordsItem in the ItemDataBound event? The above given code will work fine in the ItemCreated event. You may also try accessing it in the PreRender event.

CS:
 
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridNoRecordsItem item in RadGrid1.MasterTableView.GetItems(GridItemType.NoRecordsItem)) 
        {  
         
        } 
   } 


Regards
Shinu
0
Karen
Top achievements
Rank 1
answered on 01 Jun 2009, 08:31 AM
Thanks for your reply Shinu, but this doesn't work either, I tried both ItemCreated and ItemBound events non of them has any NoRecordsItem items, neither PreRender has, this looks realy weired.
Tags
Grid
Asked by
VS
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
VS
Top achievements
Rank 1
Karen
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or