Simple server-side row selecting and accessing row data

3 posts, 0 answers
  1. Darren
    Darren avatar
    14 posts
    Member since:
    Sep 2012

    Posted 09 Jul 2012 Link to this post

    I've been searching through the documentation to do a simple server-side select and access the data in that row. I found this page here (http://www.telerik.com/help/aspnet-ajax/grid-retrieve-primary-key-field-values-for-items.html) and used a line from the sample code:

    RadGrid1.SelectedItems[0].GetDataKeyValue("CustomerID").ToString()

    Visual Studio gives me an error of "'Telerik.Web.UI.GridItem' does not contain a definition for 'GetDataKeyValue' and no extension method 'GetDataKeyValue' accepting a first argument of type 'Telerik.Web.UI.GridItem' could be found (are you missing a using directive or an assembly reference?)"

    I tried a different route using this:

    grd.SelectedItems[0].Cells[1].Text

    but this doesn't return anything at runtime, regardless of the index I use for the cells collection.

    Please advise. Thanks guys!

  2. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 09 Jul 2012 Link to this post

    Hi Darren,

    Try casting RadGrid1.SelectedItems[0] as a GridDataItem. 

    I hope this helps!
    Casey

    GridDataItem selItem = RadGrid1.SelectedItems[0] as GridDataItem;
    selItem.GetDataKeyValue("CustomerID").ToString();

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Darren
    Darren avatar
    14 posts
    Member since:
    Sep 2012

    Posted 09 Jul 2012 Link to this post

    That worked. Thank you!
Back to Top