Hi There,
I'm just starting to use the RadGrid and I can't see how to access the data from GridCommandEventArgs.
I have a simple grid bound to an ObjectDataSource that is a .NET generated dataset (a .xsd file in the App_Code folder).
I have set up the grid so there is a delete button on each line.
Because the dataset uses more than 1 table and the Select uses a Join I cannot use the Delete/Update commands from the dataset ( as Visual Studio can't generate the SQL for Joined tables).
So I plan to capture the Delete command and do my changes to the dataset in that method and then update back to the database.
However, I do not know how to reference the record (row) on which Delete was pressed. I need this to get the unique ID for the record. Once I have this reference I can use it to find the records other fields and edit or otherwise manipulate the data.
I thought this might return the first column in the record but apparantly not.
protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
{
string ID = (string)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["RoleName"]; <-------This does not work
string ID2 = (string)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][0]; <-------This does not work
}
I have no DataKeyValues set in the aspx file because ( I believe) I generate the field names from the dataset
How do I reference the row?
Is this the right way to deal with this problem?
Thanks for any help
Richard
I'm just starting to use the RadGrid and I can't see how to access the data from GridCommandEventArgs.
I have a simple grid bound to an ObjectDataSource that is a .NET generated dataset (a .xsd file in the App_Code folder).
I have set up the grid so there is a delete button on each line.
Because the dataset uses more than 1 table and the Select uses a Join I cannot use the Delete/Update commands from the dataset ( as Visual Studio can't generate the SQL for Joined tables).
So I plan to capture the Delete command and do my changes to the dataset in that method and then update back to the database.
However, I do not know how to reference the record (row) on which Delete was pressed. I need this to get the unique ID for the record. Once I have this reference I can use it to find the records other fields and edit or otherwise manipulate the data.
I thought this might return the first column in the record but apparantly not.
protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
{
string ID = (string)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["RoleName"]; <-------This does not work
string ID2 = (string)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][0]; <-------This does not work
}
I have no DataKeyValues set in the aspx file because ( I believe) I generate the field names from the dataset
How do I reference the row?
Is this the right way to deal with this problem?
Thanks for any help
Richard