Using SelectParameter

Posts   
 
    
Gayane
User
Posts: 10
Joined: 14-Apr-2008
# Posted on: 30-Sep-2008 10:29:41   

I have datasource, but i dont want it to return all rows from db. I added select parameter and connected it to session field and i supposed to get only the rows which fields are equal to session field, but i got all rows. How I must use SelectParameter to to my task ?

Thanks in advance.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Sep-2008 11:25:22   

Would you please post a code snippet of the aspx declaration of the datasource with the SelectParameters?

Gayane
User
Posts: 10
Joined: 14-Apr-2008
# Posted on: 30-Sep-2008 12:21:48   

Here is my code


<llblgenpro:LLBLGenProDataSource ID="shipperDS" runat="server" 
                   DataContainerType="EntityCollection"   EntityCollectionTypeName="ElectronicBorder.CollectionClasses.EbShipperConsigneeCollection, ElectronicBorder">
                        <SelectParameters>
                            <asp:SessionParameter DefaultValue="1" Name="CompanyInfoId" 
                                SessionField="companyid" Type="Int32"  />
                        </SelectParameters>
                    </llblgenpro:LLBLGenProDataSource>

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Sep-2008 13:20:16   

I can't reproduce it, the following works very well with me without writing a single line of code, all done at Design-Time.

        Test Session Parameters<br />
        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductId" DataSourceID="LLBLGenProDataSource2">
            <Columns>
                <asp:BoundField DataField="ProductId" HeaderText="ProductId" InsertVisible="False"
                    ReadOnly="True" SortExpression="ProductId" />
                <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
                <asp:BoundField DataField="SupplierId" HeaderText="SupplierId" SortExpression="SupplierId" />
                <asp:BoundField DataField="CategoryId" HeaderText="CategoryId" SortExpression="CategoryId" />
                <asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit" />
                <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
                <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
                <asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
                <asp:BoundField DataField="ReorderLevel" HeaderText="ReorderLevel" SortExpression="ReorderLevel" />
                <asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" />
            </Columns>
        </asp:GridView>
        <llblgenpro:LLBLGenProDataSource ID="LLBLGenProDataSource2" runat="server" 
            EnablePaging="True" DataContainerType="EntityCollection" EntityCollectionTypeName="Norhthwind.CollectionClasses.ProductsCollection, Norhthwind">
            <SelectParameters>
                <asp:SessionParameter DefaultValue="1" Name="CategoryId" SessionField="CatId" />
            </SelectParameters>
        </llblgenpro:LLBLGenProDataSource>      

Are you sure the EbShipperConsigneeEntity has a CompanyInfoId field? (check the spelling) Which version of LLBLGen Pro runtime library are you using?

Gayane
User
Posts: 10
Joined: 14-Apr-2008
# Posted on: 30-Sep-2008 14:56:48   

The only difference is that i dont have that field in the grid. When i add the field to grid it works.

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Sep-2008 16:26:24   

Strange, coz when I remove the CategoryId from the Grid the SelectParameters still works fine.

For this repro I used the latest release of v.2.5 & V.S.2005 (Selfservicing Template Set)

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 01-Oct-2008 08:06:31   

Check the casing of the parameter names. e.g CompanyId and companyid will refer to different values even with a case insenitive database.