I select the delete button and it takes me to the event but I can't get the information about the row I'm deleting. It says the selected row is -1 when it's actually the third row. I have to pass the information to a structure befor the record can be deleted. How do I get this information?
Having a problem with my datagrid
Collapse
X
-
Don't really have much. My intentions are to take several values in the gridrow and pass them to a class that properly deletes the record. Below is all I have for the row deleted event.
Code:protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e) { BLL_SelfService.DelPhnRec(Profile.Employees.EmpId,Convert.ToInt16(GridView1.SelectedRow.Cells[0]),Convert.ToInt16(GridView1.SelectedRow.Cells[1]),Convert.ToString(GridView1.SelectedRow.Cells[2])); }
Comment
-
You shouldn't be trying to get the Selected Row..
You retrieve the row that the user wants to delete by getting the RowIndex from the "e" parameter (from the GridViewDeleteE ventArgs passed into the method).
Code:Private Sub myGridView_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles myGridView.RowDeleting Dim row = GV_Groups.Rows(e.RowIndex) End Sub
Code:void myGridView_RowDeleting(Object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e ) { GridViewRow row = GV_Groups.Rows[e.RowIndex]; }
Comment
Comment