Get item to delete from GridCommandEventArgs

2 posts, 1 answers
  1. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 23 Sep 2009 Link to this post


    I'm trying to delete a record from the RadGrid.
    So i'm handling the ondeletecommand like this:

    protected void AppointmentsGrid_DeleteCommand( object source, GridCommandEventArgs e )  
          DALDataContext dc = new DALDataContext();  
          int appointmentID = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["AppointmentID"];  

    The code above works fine, but this is not an easy way to get the appointmentID.
    Unfortunately i can't the following code to work:

    DALDataContext dc = new DALDataContext();  
    vw_Appointment appointment = (vw_Appointment)e.Item.DataItem;  

    Because the dataitem seems to be null all the time??
    Is there an explanation for this?
  2. Answer
    Vlad avatar
    11100 posts

    Posted 26 Sep 2009 Link to this post


    DataItem is available only during data binding exactly in the same way as in standard MS GridView and DataGrid.

    Kind regards,
    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.
  3. Telerik UI for ASP.NET Core is out
Back to Top