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

Hiding a row

5 Answers 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jugoslav
Top achievements
Rank 1
Jugoslav asked on 23 Sep 2011, 10:04 AM
How do i do that?
I tried something like following:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
    ' display only items with images provided
    Dim item As GridDataItem = CType(e.Item, GridDataItem)
    If DataBinder.Eval(item.DataItem, "Image").ToString = "" Then
        ' do not show up the record/row
    End If
End Sub

Thank you


5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Sep 2011, 11:01 AM
Hello Jugoslav,

Here is a sample code to achieve the same.
VB:
Protected Sub RAdGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim s As String = item("EmployeeID").Text
        If s = "5" Then
            item.Display = False
        End If
    End If
End Sub

Thanks,
Princy.
0
Jugoslav
Top achievements
Rank 1
answered on 23 Sep 2011, 01:06 PM
Ok i already found a thread with your reply/solution. Actually i am more concerned about the hidden items. For instance i may want to iterate all the items one by one ignoring page and ignoring the hidden items. How it's possible? Thanks for the previous reply it is much appreciated.
0
Jugoslav
Top achievements
Rank 1
answered on 26 Sep 2011, 02:44 PM
EDIT: This is the deal; i am using CUSTOM PAGING retrieving say 20 items per recordset. It often happens that all the 20 items should be hidden so i end up with an empty page in the RadGrid. Odd right?
Maybe i should check the image existence in the SQL code? What do you suggest? THANK YOU SO MUCH
0
Marin
Telerik team
answered on 28 Sep 2011, 05:52 PM
Hi Jugoslav,

 I believe it is more appropriate to make those operations on a data level, before the records are passed as a datasource to the grid. If you do not want to show a certain record why bind it to the grid then. My suggestion is to check whether the records correspond to a certain condition before they are bound to the grid either on database level or in code behind in NeedDataSource event or the Selecting event of the SqlDataSource control depending on what binding you use. If you end up that none of the records should be shown you can make another query to retrieve more records or use a NoRecords template to notify the user that there are no items on this page.

Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Jugoslav
Top achievements
Rank 1
answered on 29 Sep 2011, 01:15 AM
Ok this is not related to your controls anymore so you don't have to reply if you don't want.
My original idea was to do it on a data level within Stored Procedure. But my problem was that i am not able to use the xp_fileexist in the where clause.

PSEUDO CODE:
SELECT blahblah ... WHERE (xp_fileexist ColumnThatContainsTheFileNames)

But it seems that it cannot be used in this way :( unfortunately

Any other ideas about how do i retrieve only data in which columnthatcontainsfilename value exists as file on the server?

Thank you so much
Tags
Grid
Asked by
Jugoslav
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jugoslav
Top achievements
Rank 1
Marin
Telerik team
Share this question
or