Hi,
I have a GridView that is representing a DataSet in the a Session variable.
How can I get the GridView's selected row index from RowDeleting event handler?
or delete a row from the DataSet in the session in the RowDeleting event?
I want to do the following but the selected index is -1
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim index As Integer = GridView1.SelectedIndex
' Get the currently selected row using the SelectedRow property.
Dim ds As DataSet = Session("TransferTo")
Dim dt As DataTable = ds.Tables("Transfer_To")
dt.Rows(index).Delete()
GridView1.DeleteRow(index)
End Sub Thanks in advance.
|
Gaurish KumarPosted Jul 28, 2009, 11:48 PM
for RowDeleting event you can get the row index with e.RowIndex
and on deleting event if you want to get the row, try this
GridView1.Rows[e.RowIndex]
SharebPosted Jul 29, 2009, 12:10 AM
Now it's solved.
SharebPosted Jul 28, 2009, 9:51 AM
Gaurish KumarPosted Jul 28, 2009, 5:13 AM
Try this for find out the selectedindex of the grid