Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: DataGrid_DeleteCommand is not working!! Pls Help!!...


Message #1 by comching@y... on Tue, 18 Feb 2003 10:14:25
Hi All,

I'm trying to delete a row from the DataGrid, which has data populated 
from a xml document.  The problem is this: I have loaded the data from the 
xml into a DataView.table and then set the DataGrid's datasource to the 
DataView.  But somehow, that row being clicked "Delete" does not get 
deleted away, but some other row did!!  And I had a DataView.Sort called 
before the DataGrid.DataSource, does this affect the index when it's 
passed into DataView.Table.Rows.RemoveAt(e.Item.ItemIndex)??

Here's part of the code, the page_load and DataGrid_DeleteCommand, where 
the data in the DataView is being sorted before databind() is called.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles MyBase.Load
        If Not Session("AccountList") Is Nothing Then
            ADataView.Table = CType(Session("AccountList"), DataTable)
            ADataView.Sort = "Account_No, Account_Level"
            DataGrid.DataSource = ADataView
        End If
End Sub

.... other functions ....

Sub DataGrid_DeleteCommand(ByVal source As Object, ByVal e As 
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles 
DataGrid.DeleteCommand
        ADataView.Table.Rows.RemoveAt(e.Item.ItemIndex)

        Session("AccountList") = ADataView.Table
        ADataView.Sort = "Account_No, Account_Level"
        DataGrid.DataSource = ADataView
        DataGrid.DataBind()
End Sub

Appreciate your help on the above!!

  Return to Index