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

RadGrid delete (RowDeleting)

1 Answer 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sayitfast
Top achievements
Rank 2
Iron
sayitfast asked on 24 Aug 2010, 02:59 AM
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. 

Thanks!!!

1 Answer, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 24 Aug 2010, 10:01 AM
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,
Sebastian
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
Tags
Grid
Asked by
sayitfast
Top achievements
Rank 2
Iron
Answers by
Sebastian
Telerik team
Share this question
or