croker10 0 Junior Poster in Training

Hi all,

I have a grid view I am trying to use, and it displays a large number of pill codes, (thousands) that I would like to be able to filter down. I have set up a dropdown list that gives the different options to filter on, basically every letter in the alphabet and 0-9. I beleive that I have set up the grid view and object data source correctly, but it does not seem to work.

When no filter is applied, all the data appears, but when any filter, other than "0" is used, the GridView does not show.

I'm at a loss on this one, so if anyone sees what's going wrong here, I'd love to know.

Here is the asp code:

<asp:DropDownList ID="ddlFilterList" runat="server" AutoPostBack="true">
        <asp:ListItem Value="%" Text="Filter Codes" />
        <asp:ListItem Value="A" Text="A" />
        <asp:ListItem Value="B" Text="B" />
        <asp:ListItem Value="C" Text="C" />

         //the rest of the letters and numbers go here....

        <asp:ListItem Value="8" Text="8" />
        <asp:ListItem Value="9" Text="9" />
        <asp:GridView ID="PillsGridView" runat="server" 
            AllowPaging="true" PageSize="15" PagerSettings-Mode="NumericFirstLast" AllowSorting="true" PagerStyle-HorizontalAlign="Center" PagerStyle-Font-Bold="true"
            AutoGenerateColumns="false" OnSelectedIndexChanged="pillDetails" DataSourceID="PillsList_DataSource" >
                <asp:HyperLinkField HeaderText="Pill Code" DataTextField="strPillCode" SortExpression="strPillCode" HeaderStyle-Width="100px" ControlStyle-Width="75px" DataNavigateUrlFields="strPillCode" DataNavigateUrlFormatString="PillDetail.aspx?pillcode={0}" />
                <asp:BoundField HeaderText="Description" DataField="strDescription"  HeaderStyle-Width="300px" ControlStyle-Width="200px" ReadOnly="true" />
                <asp:BoundField HeaderText="Wav File" DataField="strWav" HeaderStyle-Width="50px"  ControlStyle-Width="50px" ReadOnly="true" />
                <asp:BoundField HeaderText="Force Transfer" DataField="bForce" HeaderStyle-Width="50px"  ControlStyle-Width="50px" ReadOnly="true" />
                <asp:BoundField HeaderText="Active Status" DataField="bActive" HeaderStyle-Width="50px"  ControlStyle-Width="50px" ReadOnly="true" />
        <asp:ObjectDataSource ID="PillsList_DataSource" runat="server" TypeName="Web.Code.BusinessLayer.BusinessManager.PillManager"
        SelectMethod="GetPills"  SelectCountMethod="Count"  EnablePaging="true" FilterExpression="strPillCode like '{0}%'" >
                <asp:ControlParameter Name="FilterList" ControlID="ddlFilterList" PropertyName="SelectedValue" />

and here is the C# code for the data source:

public int Count()
            return db.PillCodes.Count();

        public DataSet getPills(int startRowIndex, int maximumRows)
                var PillQuery = (from PillCode in db.PillCodes select PillCode);
                return convertToTable(PillQuery.Skip(startRowIndex).Take(maximumRows).ToList<PillCode>());
public DataSet convertToTable(List<PillCode> pcList)
            DataSet ds = new DataSet("Table");

            DataTable dt = new DataTable();


            foreach (PillCode pc in pcList)


            return ds;


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.