Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
903
e.Row.DataKey always returning value from first page
posted

 

Below is a schematic of my code, the full thing would be too much.  I hope it makes sense. I have a problem that in the DeleteRow event, trying to read the DataKey,  the RowEventArgs always returns the value from the equivalent row on the first page of the grid even if I have paged further.

The way I do it may not be right (I am very open to suggestions) but it works for other webforms in my app where I am using an SQLDataSource rather than the WebHierarchichalDatSource I am using here.

I also thought it used to work here but somewhere along the line (maybe after 10.1?) (I am on version 10.2.20102.101) it stopped working.  My users don't appear to have noticed yet!


An UltraWebGrid

<ig:WebHierarchicalDataSource ID="WebHierarchicalDS1" runat="server">
    <DataRelations>
        <ig:DataRelation ChildColumns="Transport Order ID"
            ChildDataViewID="SqlDataSource2_DefaultView" ParentColumns="Transport_Order_ID"
            ParentDataViewID="SqlDataSource1_DefaultView" />
    </DataRelations>
    <DataViews>
        <ig:DataView ID="SqlDataSource1_DefaultView" DataMember="DefaultView"
            DataSourceID="SqlDataSource1" />
        <ig:DataView ID="SqlDataSource2_DefaultView" DataMember="DefaultView"
            DataSourceID="SqlDataSource2" />
    </DataViews>
</ig:WebHierarchicalDataSource


' Code Structure

Page_Load
    If not Postback
        LoadDataset
    endif
End Page_Load


Sub LoadDatset
    Set UltraWebGrid.DataSourceID
    UltrawebGrid.DataBind
End Sub

sub PrepareDataset
    Build SelectCommand for SQLDataSource1
End Sub

Sub SelectionChanged
    LoadDataSet
End SelectionChanged

UltraWebGrid_DataBinding
    PrepareDataSet
End Sub

UltraWebGrid_SortColumn
    LoadDataSet
End Sub

UltraWebGrid_PageIndexChanged
    LoadDataSet
End Sub


UltraWebGrid_DeleteRow(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles UltraWebGrid.DeleteRow

         DeleteRowID = e.Row.DataKey    'Always Returns the DataKey from the first page

End DeleteRow

  • 903
    posted

    OK, it looks like this post is in the wrong forum, so it may appear in the Classic Controls section.  I hadn't really noticed that the grids I use have become 'Classic'

  • 903
    posted

    After some further tests I see that the CurrentPageIndex is correct when DeleteRow is called. (I am actually testing in a CellClickButton event, but I have the same problem in both)

    So the grid thinks it is on the right page it is just that the DataKeys set appears to be wrong.  And it looks like the grid Datakeys set is populated with the Keys from the first page only.