4 Answers, 1 is accepted
You can access all the items that are being deleted in the e.Items property, and get all the information you need from there.
I want to retrive a cell value to pass as a paramater to a stored procedure to delete records from the database.
If you need the value from a cell that is not bound to any property in the row's object, you can use the GridView's ItemContainerGenerator to get the row in which the item is located. Mind however that when the RowVirtualization is turned on and the item that you are deleting is not in the ViewPort, this won't work. The reason is when an item is not visible there is no row realized for it in order to boost the performance of the GridView.
Hope this helps!
Nik
the Telerik team
<
telerik:RadGridView
HorizontalAlignment
=
"Left"
Margin
=
"153,20,0,0"
Name
=
"FilesLoadedGrid"
VerticalAlignment
=
"Top"
Height
=
"233"
Width
=
"439"
AutoGenerateColumns
=
"False"
CanUserFreezeColumns
=
"False"
CanUserReorderColumns
=
"False"
CanUserResizeColumns
=
"False"
RowIndicatorVisibility
=
"Collapsed"
ShowGroupPanel
=
"False"
AlternationCount
=
"2"
AlternateRowBackground
=
"Cornsilk"
Deleting
=
"FileDeleted"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewColumn
>
<
telerik:GridViewColumn.CellTemplate
>
<
DataTemplate
>
<
telerik:RadButton
Content
=
"Delete"
Command
=
"telerikGrid:RadGridViewCommands.Delete"
CommandParameter
=
"{Binding SelectedItem}"
/>
</
DataTemplate
>
</
telerik:GridViewColumn.CellTemplate
>
</
telerik:GridViewColumn
>
<
telerik:GridViewDataColumn
Header
=
"Loaded File"
Name
=
"FileLoaded"
DataMemberBinding
=
"{Binding LoadedFile}"
Width
=
"*"
>
</
telerik:GridViewDataColumn
>
</
telerik:RadGridView.Columns
>
The grid is loaded with a datable.
I am using the Deleting how do I get the selected row value for the FileLoaded cell
I just need to add the delet functionality but I know I am getting the file name from th deleted record.
public void FileDeleted(object sender, GridViewDeletingEventArgs e)
{
foreach (object itemToDelete in e.Items)
{
string fileName = (((DataRowView)itemToDelete).Row.ItemArray).GetValue(0).ToString();
MessageBox.Show(fileName);
}
}
Glad to see you found the right way on your own. Nevertheless, if you need any further help, don't hesitate to ask!
All the best,Nik
the Telerik team