LLBLGenProDataSource2 where clause not happening

Posts   
 
    
jovball
User
Posts: 443
Joined: 23-Jan-2005
# Posted on: 01-Sep-2006 09:16:12   

I am trying to see what the LLBLGenProDataSource2 offers for an ASP.NET application. I have the following page and the grid always returns all records. Why isn't it picking up on the Select parameter?

Joel Reinford Data Management Solutions LLC


    <asp:TextBox ID="TextBox1" runat="server">593</asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Button" /><br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ActivityId"
        DataSourceID="LLBLGenProDataSource2_1" AllowPaging="True">
        <Columns>
            <asp:BoundField DataField="ActivityId" HeaderText="ActivityId" ReadOnly="True" SortExpression="ActivityId" />
            <asp:BoundField DataField="PartyId" HeaderText="PartyId" SortExpression="PartyId" />
            <asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" />
            <asp:BoundField DataField="ActivityDate" HeaderText="ActivityDate" SortExpression="ActivityDate" />
        </Columns>
    </asp:GridView>
    <cc1:LLBLGenProDataSource2 ID="LLBLGenProDataSource2_1" runat="server" AdapterTypeName="DMS.DAL.DbSpecific.DataAccessAdapter, DMS.VbOfficials.DAL.DbSpecific"
        DataContainerType="EntityCollection" EntityFactoryTypeName="DMS.DAL.FactoryClasses.ActivityEntityFactory, DMS.DAL">
        <SelectParameters>
            <asp:ControlParameter ControlID="TextBox1" DefaultValue="593" Name="PartyID" PropertyName="Text"
                Type="Int32" />
        </SelectParameters>
    </cc1:LLBLGenProDataSource2>

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 01-Sep-2006 10:52:57   

What does happen if you fill in a value in the textbox. The datasourcecontrol simply consumes what it gets from the bound grid and selectparameters offered by the asp.net framework. so if there are no selectparameters in that data, it won't use one.

Frans Bouma | Lead developer LLBLGen Pro
jovball
User
Posts: 443
Joined: 23-Jan-2005
# Posted on: 01-Sep-2006 15:45:53   

In the code posted above, I actually hard-coded a value into the textbox in one of my attempts to get the thing working. I can change the value of the textbox, remove the default value from the select parameter and it just doesn't work.

I am using adapter scenario with the Aug-26 runtime.

I guess I will take a shot at doing this with Northwind and see if I can get it to work there.

Joel Reinford

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 01-Sep-2006 15:49:50   

Most probably the selectparameter can't find a corresponding field in the returned results to filter upon.

Check the PartyID != PartyId ....take care of the case sensetive differences.

jovball
User
Posts: 443
Joined: 23-Jan-2005
# Posted on: 01-Sep-2006 16:32:09   

Matching the case of the field name was the answer.

The database column name is PartyID but I have EnforcePascalCasing turned on so the LLBLGen entity shows it as PartyId. The gridview picked up the fields from the LLBLGenDataSource2 and so it also shows it as PartyId.

One interesting thing I discovered after getting it working. The gridview doesn't care about the case of the field name (I already knew that) and everything will work just fine as long as the case of the fieldname in the LLBLGen entity matches the case of the value in the Name attribute of the parameter.

Thanks for your help, now it's time to do some more playing with this!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 01-Sep-2006 17:08:22   

Yes casing is important in this. It can't be case insensitive, as it will otherwise potentially break C# code which has properties of different casing. (not very common but if one has, it should work).

Frans Bouma | Lead developer LLBLGen Pro