ASP:GridView does not show data with ObjectdataSource

Posted by Kashif on Stack Overflow See other posts from Stack Overflow or by Kashif
Published on 2010-02-04T20:30:35Z Indexed on 2010/04/03 5:43 UTC
Read the original article Hit count: 271

I have been trying to bind a DataGrid with ObjectDataSource having custom paging but no output is display on my usercontrol. Here is the code I am using

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    DataKeyNames="LeadId" DataSourceID="dsBuyingLead1" AllowPaging="True">
    <Columns>
        <asp:BoundField DataField="Subject"
            HeaderText="Subject" ReadOnly="True" />
        <asp:BoundField DataField="ExpiryDate"
            HeaderText="ExpiryDate" ReadOnly="True" />
    </Columns>
</asp:GridView> 

<asp:ObjectDataSource ID="dsBuyingLead1" runat="server" EnablePaging="True"
    DataObjectTypeName="Modules.SearchBuyingLeadInfo"
    OldValuesParameterFormatString="original_{0}"
    SelectMethod="GetAllBuyingLeads" 
    StartRowIndexParameterName="startRow"
    MaximumRowsParameterName="maximumRows"
    SelectCountMethod="GetAllBuyingLeadsCount"
    TypeName="Modules.SearchController">
    <SelectParameters>
        <asp:QueryStringParameter Name="searchText"
            QueryStringField="q" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>

Here are my methods from SearchController class:

[DataObjectMethod(DataObjectMethodType.Select)]
public static long GetAllBuyingLeadsCount(string searchText)
{
    return DataProvider.Instance().GetAllBuyingLeadsCount(searchText);
}

[DataObjectMethod(DataObjectMethodType.Select)]
public static List<SearchBuyingLeadInfo> GetAllBuyingLeads
    (string searchText, int startRow, int maximumRows)
{
    List<SearchBuyingLeadInfo> l = CBO.FillCollection<SearchBuyingLeadInfo>
    (
        DataProvider.Instance()
            .GetAllBuyingLeadswithText(searchText, startRow, maximumRows)
    );

    return l;
}

Where SearchBuyingLeadInfo is my Data Access Object class

I have verified by setting up break points that both GetAllBuyingLeadsCount and GetAllBuyingLeads return non-zero values but unfortunately nothing is displayed on the grid. Only the column headers are displayed.

Can anyone tell me what am I missing?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about gridview