I'm using a RadGrid object and I want to find an item by its keys values.
The dictionary is a Hashtable that is filled with a foreach iteration.
Hashtable d =
new
Hasthable();
for
(
int
i = 0; i < partK.Length; i++)
{
d.Add(partK[i], partV[i]);
}
GridDataItem[] gdis = listGrid.MasterTableView.FindItemsByKeyValues(d);
I'm using the following example. Dictionary d is filled with the following values:
- d Count = 2 System.Collections.Hashtable
+ ["MVFCodCIA"] "035"
+ ["MVFRefXRisk"] "70000598"
At the listGrid, if I make the following question at the inspection window I have this:
listGrid.Items[7].KeyValues "{MVFCodCIA:\"035\",MVFRefXRisk:\"70000598\"}" string
So the item exists.
When I debug the code, gdis.Length is 0, so the FindItemsByKeyValues doesn't find me the item I'm searching.
Am I doing something wrong?
Thanks.
8 Answers, 1 is accepted
The code and the approach you are using is indeed proper. However, can you confirm you have added the MVFCodCIA and MVFRefXRisk fields to the DataKeyNames collection of the MasterTableView?
Kind regards,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

I'm running into the same issue where the FindItemsByKeyValues returns a 0 length GridDataItem array.
I have verified that the datakeys are declared on the master table.
Thanks for your assitance in advance.
Sean
Please find the attached sample illustrating how the method in question works. Can you try it on your end and let me know how it goes and what differs in your case.
Best wishes,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Thank you for the response and the example app. I've tried to implement this into our project without success. The items object comes up with a 0 length.
Here is a brief background on our scenario. RadGrid1 can contain row data that belongs to a user. We have a composite key (or multiple DataKeys) on this RadGrid1. ASSIGNED_TECH, HD_TICKET_ID So I've modified the hashtable to reflect that:
Dim myValues As New Hashtable
myValues("ASSIGNED_TECH") = Session("emailAddress")
myValues("HD_TICKET_ID") = Session("ticket")
When I apply the FindItemsByKeyValues it looks like this:
Dim myAssignments As GridItem() = RadGridAssignments.MasterTableView.FindItemsByKeyValues(myValues)
myAssignments returns a 0 length. We'd like to access the GridItemData eventually too. So i'm not sure if the GridItem object can be replaced with the GridDataItem object or not.
We are then using this in another grids (RadGrid2) ItemDataBound event to prepopulate certain fields in a Insert Form Template.
Hope this helps narrow something down.
Thanks!
Sean
Indeed, you can cast each of the grid items to GridDataItem as all grid items (data item, pager item, filtering item, etc.) inherit from the GridItem class.
However can you send me a sample of your grid in a formal support ticket? Thus I will run it and debug it locally and be able to find what went wrong there.
All the best,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

In our application we have a form to insert data, and the we refresh a list with all the data table. We want to select the recently added register, but it's possible it will be at another page (and it's not mandatory it will be the last register).
Is there any way to look for a register and mark it as the selected item?
There are two approaches you can use to achieve your goal:
- You should either loop through all grid pages and their items to find the specific item.
- Or you can find which is the index of the item in the datasource bound to the grid directly. Then calculate on which page and what item index the record would have in the grid. Navigate to that page and add the index to the SelectedIndexes collection.
Check it out and let me know if you have further questions.
Greetings,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Thanks.