RadGrid delete (RowDeleting)

2 posts, 1 answers
  1. sayitfast
    sayitfast avatar
    57 posts
    Member since:
    Oct 2006

    Posted 23 Aug 2010 Link to this post

    Ok... on a standard GridView and I can do this:

    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        string fileName = e.Values["FullName"].ToString();
        if (File.Exists(Server.MapPath("~/Uploads/" + fileName)))
            File.Delete(Server.MapPath("~/Uploads/" + fileName));

    Can someone please tell me the equivalent uisng the RadGrid... I'm pulling my hair out. 

  2. Answer
    Sebastian avatar
    9934 posts

    Posted 24 Aug 2010 Link to this post

    Hi sayitfast,

    One possible option would be to wire the OnItemDeleted grid event (fired when you perform automatic delete operation by assigning a data source control to the grid). In this case you will be able to fetch the value from the FullName grid column inside the handler as follows:
    Copy Code
    string fileName = e.Item["FullName"].Text;

    Note that this event is fired when the actual delete operation is already processed. In case you would like to perform conditional check before this operation takes place, you can intercept the OnDeleting event of the corresponding data source control and check the value of the FullName field using the relevant data source control parameter name.

    In case you implemented manual delete operation for your RadGrid, consider hooking the DeleteCommand server event and extract the value of the FullName field as follows:
    Copy Code
    string fileName = (e.Item as GridDataItem)["FullName"].Text;

    Best regards,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top