User Profile & Activity

Steve Extend Member
Posted: January 3, 2013 11:44 AM

ISData Adapter Code:

    public class CustomersISDataAdapter
    {
        public CustomersISDataAdapter()
        {
        }
        private Customers _lastCustomers = null;
        public CustomersISDataCollection GetData(string sortExpression, int maximumRows, int startRowIndex)
        {
            Customers items = Customers.GetCustomers(startRowIndex, maximumRows);
            this._lastCustomers = items;
            CustomersISDataCollection dataCollection = CustomersISDataCollection.CreateISDataCollection(items);
            return dataCollection;
        }
        public int SelectCount(string sortExpression)
        {
            return this._lastCustomers.MaxRowIndex;
        }
    }

For some reason the GetData method is always called twice.

It's called twice when the page loads and twice everytime I page.

No grid events are being handled in the code behind.

I have two questions:



1) How can I stop the GetData call being made twice.

2) Why does the return object of GetData need to inherit IHierarchicalList. I can do theGrid.DataSource = theCustomers, where theCustomers is of type CUstomers, and it works fine...but returning a Customers object gives an error when using the ISDataSource saying the collection must implement IHierarchicalList. This means I have to take my customer objects and add them to a special collection before I return them.

 

cheers,

 

Steve

Posted: January 3, 2013 11:34 AM

Hi,

I have this almost working now.

Page Source Source:

<ISWebGrid:WebGrid ID="WebGrid2" runat="server" Height="250px" 
    UseDefaultStyle="True" Width="500px" DataSourceID="ISDataSource1">
    <LayoutSettings PagingLoadMode="Custom" PagingMode="ClassicPaging" 
        PagingStyleUI="Slider" PagingDataRetrievalMode="ReturnPartialRows" 
        PagingSize="20">
    </LayoutSettings>
    <RootTable>
        <Columns>
            <ISWebGrid:WebGridColumn Name="CustomerId" Caption="Customer Id" DataMember="CustomerId" />
            <ISWebGrid:WebGridColumn Name="DisplayName" Caption="Display Name" DataMember="DisplayName" Width="200"/>
        </Columns>
    </RootTable>
</ISWebGrid:WebGrid>
<ISDataSource:ISDataSource ID="ISDataSource1" runat="server" 
    SchemaType="CustomObject" LoadOnDemand="true">
    <Tables>
        <ISDataSource:ISDataSourceTable SelectMethod="GetData" SelectCountMethod="SelectCount" TableName="Customers" EnablePaging="true"
            TypeName="WebGridPaging.CustomersISDataAdapter" >
        </ISDataSource:ISDataSourceTable>
    </Tables>
</ISDataSource:ISDataSource>
All times are GMT -5. The time now is 3:33 PM.
Previous Next