Cannot get bidirectional binding for dropdownlist

Posts   
 
    
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 30-Oct-2009 18:51:38   

I have a simple requirement:

  1. ASP.Net FormView control
  2. FormView uses LLBLgen datasource for "Customer"
  3. In FormView there is a dropdownlist which uses ObjectDataSource to populate list, bound to Customer.DefaultLocationId
 <asp:DropDownList ID="DefaultLocationDropDownList" runat="server"  SelectedValue='<%# Bind("DefaultLocationID") %>' DataTextField="LocationName" DataValueField="LocationId" DataSourceId="ObjectDataSource1" >
                    </asp:DropDownList>

I have looked at the LLBL example code and it looks the same as mine. The only difference I can see is that the samples use an LLBL data control to bind the list as well as the FormView itself. I am using LLBL for the FormView, but an ObjectDataSource for the list part of the dropdown (the list populates fine). My LLBL data control is set to LivePersistence=true. All fields are persisted no problem except for the dropdown list.

A half-day wasted so far confused What can I do here?

Thanks!

Update: In the FormView1_ItemUpdating and FormView1_ItemUpdated methods I can see the e.NewValues and e.OldValues collections. The value from the dropdownlist is correctly changed from e.g., 10 to 6. I seems like the FormView and the dropdownlist are working -- why won't LLBLgen datasource control recognize this change!?!

Also - I removed the ObjectDataSource and used instead the simplest possible dropdownlist and the problem still exists:

<asp:DropDownList ID="DefaultLocationDropDownList" runat="server" SelectedValue='<%# Bind("DefaultLocationID") %>' >
                    <asp:ListItem Text="Sample 10" Value="10"></asp:ListItem>
                    <asp:ListItem Text="Sample 4" Value="4"></asp:ListItem>
                    <asp:ListItem Text="Sample 5" Value="5"></asp:ListItem>
                    <asp:ListItem Text="Sample 6" Value="6"></asp:ListItem>
                    <asp:ListItem Text="Sample 7" Value="7"></asp:ListItem>
                    </asp:DropDownList>

Further update, another question:

After working with this stuff for the whole day either I am doing something very wrong (quite possible) or else the LLBLgen datasource control using LivePersistence s very flaky in combination with the FormView control. I have gotten an updatable FormView exactly once all day today. Other attempts using extremely simple entities have failed (data displays, allows edit, update action does not throw any errors, data is NOT persisted.

Question: Is the DetailsView control a better match to the LLBLgen data control using LivePersistence? The examples use this, and when I tried a simple example of my own it worked the first time. I don't want to go down this road unless I am sure it is reasonably stable. If not I'll revert to old-fashioned manual control field-by-field (ugh).

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Oct-2009 20:28:32   

Hi Steve,

Please post the declarative aspx for the LLBLGenProDataSource and the FormView. Also post your LLBLGen Pro runtime library version (http://llblgen.com/tinyforum/Messages.aspx?ThreadID=7720).

David Elizondo | LLBLGen Support Team
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 30-Oct-2009 20:31:35   
<%@ Register assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" namespace="SD.LLBLGen.Pro.ORMSupportClasses" tagprefix="llblgenpro" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register src="../Address.ascx" tagname="Address" tagprefix="uc1" %>

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="MyAccountDetail.ascx.vb" Inherits="Sunterra.MyAccountDetail" %>
    <asp:FormView ID="FormView1" runat="server" 
        DataSourceID="LLBLGenProDataSource21" DefaultMode="Edit" 
    DataKeyNames="CustomerId" Width="1000px">
         <EditItemTemplate>
        <table width="100%">
        <tr><td colspan="4">My Sunterra Account Details</td></tr>
            <tr>
                <td>
                    Customer ID:
                </td>
                <td>
                    <asp:Label ID="CustomerIDLabel1" runat="server" Text='<%# Eval("CustomerID") %>' />
                </td>
                <td>
                    Company:
                </td>
                <td>
                    <telerik:radtextbox ID="CompanyNameTextBox" runat="server" 
                        Text='<%# Bind("CompanyName") %>' />
                </td>
            </tr>
            <tr>
                <td>
                    Sunterra Number:
                </td>
                <td>
                    <telerik:radtextbox ID="SunterraNumberTextBox" runat="server" 
                        Text='<%# Bind("SunterraNumber") %>' />
                </td>
                <td>
                    Sunterra Phone:
                </td>
                <td>
                    <telerik:radtextbox ID="SunterraPhoneTextBox" runat="server" 
                        Text='<%# Bind("SunterraPhone") %>' />
                </td>
            </tr>
            <tr>
                <td>
                    First Name:
                </td>
                <td>
                    <telerik:radtextbox ID="FirstNameTextBox" runat="server" 
                        Text='<%# Bind("FirstName") %>' />
                </td>
                <td>
                    Last Name:
                </td>
                <td>
                    <telerik:radtextbox ID="LastNameTextBox" runat="server" 
                        Text='<%# Bind("LastName") %>' />
                </td>
            </tr>
            <tr>
                <td>
                    Reward Points:
                </td>
                <td>
                    <telerik:radtextbox ID="RewardPointsTextBox" runat="server" 
                        Text='<%# Bind("RewardPoints") %>' ReadOnly="True" />
                </td>
                <td>
                    Birthdate:
                </td>
                <td>
                    <telerik:radtextbox ID="BirthdateTextBox" runat="server" 
                        Text='<%# Bind("Birthdate") %>' />
                </td>
            </tr>
            <tr>
                <td>
                    Email:
                </td>
                <td>
                    <telerik:radtextbox ID="EmailTextBox" runat="server" 
                        Text='<%# Bind("Email") %>' />
                </td>
                <td>
                    Alt Email:
                </td>
                <td>
                    <telerik:radtextbox ID="AltEmailTextBox" runat="server" 
                        Text='<%# Bind("AltEmail") %>' />
                </td>
            </tr>
            <tr>
                <td>
                    Account Number:
                </td>
                <td>
                    <telerik:radtextbox ID="AccountNumberTextBox" runat="server" 
                        Text='<%# Bind("AccountNumber") %>' />
                </td>
                <td>
                    Default Location:
                </td>
                <td>
                    <telerik:RadComboBox ID="DefaultLocationDropDownList" runat="server" SelectedValue='<%# Bind("DefaultLocationID") %>' DataTextField="LocationName" DataValueField="LocationId" DataSourceId="ObjectDataSource1">
                    </telerik:RadComboBox>
                </td>
            </tr>
            <tr>
                <td>
                    Birthday Card:
                </td>
                <td>
                    <asp:CheckBox ID="ReceivesBirthdayCardCheckBox" runat="server" Checked='<%# Bind("ReceivesBirthdayCard") %>' />
                </td>
                <td>
                    Newsletter:
                </td>
                <td>
                    <asp:CheckBox ID="ReceivesNewsletterCheckBox" runat="server" Checked='<%# Bind("ReceivesNewsletter") %>' />
                </td>
            </tr>
            <tr>
                <td>
                    eLetter:
                </td>
                <td>
                    <asp:CheckBox ID="ReceivesEletterCheckBox" runat="server" Checked='<%# Bind("ReceivesEletter") %>' />
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
         </table>
        <asp:HiddenField ID="CustomerAddressIDHiddenField" runat="server" Value='<%# Bind("CustomerAddressID") %>' />
        <asp:HiddenField ID="DeliveryAddressIDHiddenField" runat="server" Value='<%# Bind("DeliveryAddressID") %>' />
        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
            Text="Update" Visible="false" />
        &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
            CommandName="Cancel" Text="Cancel" Visible="false" />
    </EditItemTemplate>
        <InsertItemTemplate>
    
        </InsertItemTemplate>
        <ItemTemplate>
            
        </ItemTemplate>
    </asp:FormView>
    <table style="width:1000px"><tr><td>Billing Address</td><td>Delivery Address</td></tr><tr>
<td>
    <uc1:Address ID="BillingAddressUserControl" runat="server" />
    </td><td>
        <uc1:Address ID="DeliveryAddressUserControl" runat="server" />
    </td></tr><tr><td colspan="2" style="text-align:right">
        <asp:ImageButton ID="SaveImageButton" runat="server" 
            ImageUrl="~/media/images/Save-48x48.png" ToolTip="Save changes" />&nbsp;
        <asp:ImageButton ID="CancelImageButton" runat="server" 
            ImageUrl="~/media/images/Cancel-48x48.png" CausesValidation="False" 
            ToolTip="Cancel and lose any changes since last Save" />
        </td></tr></table>

    <llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource21" runat="server" 
        AdapterTypeName="DAL.DatabaseSpecific.DataAccessAdapter, DALDBSpecific" 
        DataContainerType="EntityCollection" 
        EntityFactoryTypeName="DAL.FactoryClasses.CustomerEntityFactory, DAL">
    </llblgenpro:LLBLGenProDataSource2>
    
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
    OldValuesParameterFormatString="original_{0}" SelectMethod="GetLocationList" 
    TypeName="Sunterra.Repository.ListCacheRepository"></asp:ObjectDataSource>


Runtime 2.6 Final - June 6th, 2008

In the code above I reverted back to my original Telerik combo box. The same problem happened no matter which control I used (asp: dropdownlist) or what the data source was (I used straight declarative listitems as a test -- still the same problem).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39862
Joined: 17-Aug-2003
# Posted on: 01-Nov-2009 11:03:53   

please update to the latest runtime build (and runtime build nrs are given in exact dates, see the 'about this forum' topic in this forum)

Frans Bouma | Lead developer LLBLGen Pro
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 01:17:29   

File version: 2.6.8.624

Adapter / .Net 3.5

SQL Server 2008 (database running in 2005 mode)

Here is another update:

I was able to get a DetailsView to bind to a dropdownlist successfully using a LLBLgen Datasource. I cannot see that the markup was different in any significant way at all. This time I was using an Address entity instead of customer, but the same problem happened with Address using the FormView.

Here is the markup that works (the above still does not):

<llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource21" runat="server" 
    AdapterTypeName="DAL.DatabaseSpecific.DataAccessAdapter, DALDBSpecific" 
    DataContainerType="EntityCollection" 
    EntityFactoryTypeName="DAL.FactoryClasses.AddressEntityFactory, DAL" 
    CacheLocation="Session">
</llblgenpro:LLBLGenProDataSource2>
<asp:DetailsView ID="DetailsView1" runat="server"  
    DataSourceID="LLBLGenProDataSource21" DefaultMode="Edit" Height="50px" 
    Width="125px" AutoGenerateRows="False" DataKeyNames="AddressId">
    <Fields>
        <asp:BoundField DataField="AddressID" HeaderText="AddressID" 
            InsertVisible="False" ReadOnly="True" SortExpression="AddressID" />
        <asp:BoundField DataField="Address1" HeaderText="Address1" 
            SortExpression="Address1" />
        <asp:BoundField DataField="Address2" HeaderText="Address2" 
            SortExpression="Address2" />
        <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
                            <asp:TemplateField HeaderText="Province">
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddlProvince" runat="server" SelectedValue='<%# Bind("Province") %>' AppendDataBoundItems="true">
                        <asp:ListItem Value="Alberta" Text="Alberta"></asp:ListItem>
                        <asp:ListItem Value="British Columbia" Text="British Columbia"></asp:ListItem>
                        <asp:ListItem Value="Manitoba" Text="Manitoba"></asp:ListItem>
                        <asp:ListItem Value="New Brunswick" Text="New Brunswick"></asp:ListItem>
                        <asp:ListItem Value="Newfoundland and Labrador" Text="Newfoundland and Labrador"></asp:ListItem>
                        <asp:ListItem Value="Northwest Territories" Text="Northwest Territories"></asp:ListItem>
                        <asp:ListItem Value="Nova Scotia" Text="Nova Scotia"></asp:ListItem>
                        <asp:ListItem Value="Nunavut" Text="Nunavut"></asp:ListItem>
                        <asp:ListItem Value="Ontario" Text="Ontario"></asp:ListItem>
                        <asp:ListItem Value="Prince Edward Island" Text="Prince Edward Island"></asp:ListItem>
                        <asp:ListItem Value="Quebec" Text="Quebec"></asp:ListItem>
                        <asp:ListItem Value="Saskatchewan" Text="Saskatchewan"></asp:ListItem>
                        <asp:ListItem Value="Yukon" Text="Yukon"></asp:ListItem>
                            </asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
        <asp:BoundField DataField="Country" HeaderText="Country" 
            SortExpression="Country" />
        <asp:BoundField DataField="PostalCode" HeaderText="PostalCode" 
            SortExpression="PostalCode" />
        <asp:BoundField DataField="AreaCode" HeaderText="AreaCode" 
            SortExpression="AreaCode" />
        <asp:BoundField DataField="PhoneNumber" HeaderText="PhoneNumber" 
            SortExpression="PhoneNumber" />
        <asp:CommandField ShowEditButton="True" />
    </Fields>
</asp:DetailsView>

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 01:44:13   

Look there is DEFINITELY something flaky somewhere here. I just created the most basic, vanilla LiverPersistence scenario I could with my simple Customer entity. The fields all update fine except for 1 checkbox!!! On a different ascx on Friday using the exact same entity all those checkboxes worked.

Can anyone think of how this is possible? I have no problem sending you this VS.Net solution. Entire db is buildable in a few seconds from included scripts. I just haven't a clue how to proceed until I get databinding to be minimally stable. My client is expecting to see a lot of progress tomorrow afternoon, and I've spent days with these strange databinding problems. Please help!

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="cust.ascx.vb" Inherits="Sunterra.cust" %>
<%@ Register assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" namespace="SD.LLBLGen.Pro.ORMSupportClasses" tagprefix="llblgenpro" %>

<asp:FormView ID="FormView1" runat="server" 
    DataSourceID="LLBLGenProDataSource21" DefaultMode="Edit" DataKeyNames="CustomerId">
        <EditItemTemplate>
        CustomerID:
        <asp:Label ID="CustomerIDLabel1" runat="server" 
            Text='<%# Eval("CustomerID") %>' />
        <br />
        UserId:
        <asp:TextBox ID="UserIdTextBox" runat="server" Text='<%# Bind("UserId") %>' />
        <br />
        CustomerType:
        <asp:TextBox ID="CustomerTypeTextBox" runat="server" 
            Text='<%# Bind("CustomerType") %>' />
        <br />
        CompanyName:
        <asp:TextBox ID="CompanyNameTextBox" runat="server" 
            Text='<%# Bind("CompanyName") %>' />
        <br />
        SunterraNumber:
        <asp:TextBox ID="SunterraNumberTextBox" runat="server" 
            Text='<%# Bind("SunterraNumber") %>' />
        <br />
        SunterraPhone:
        <asp:TextBox ID="SunterraPhoneTextBox" runat="server" 
            Text='<%# Bind("SunterraPhone") %>' />
        <br />
        FirstName:
        <asp:TextBox ID="FirstNameTextBox" runat="server" 
            Text='<%# Bind("FirstName") %>' />
        <br />
        LastName:
        <asp:TextBox ID="LastNameTextBox" runat="server" 
            Text='<%# Bind("LastName") %>' />
        <br />
        ReceivesBirthdayCard:
        <asp:CheckBox ID="ReceivesBirthdayCardCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesBirthdayCard") %>' />
        <br />
        ReceivesNewsletter:
        <asp:CheckBox ID="ReceivesNewsletterCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesNewsletter") %>' />
        <br />
        ReceivesELetter:
        <asp:CheckBox ID="ReceivesELetterCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesELetter") %>' />
        <br />
        RewardPoints:
        <asp:TextBox ID="RewardPointsTextBox" runat="server" 
            Text='<%# Bind("RewardPoints") %>' />
        <br />
        Birthdate:
        <asp:TextBox ID="BirthdateTextBox" runat="server" 
            Text='<%# Bind("Birthdate") %>' />
        <br />
        CustomerAddressID:
        <asp:TextBox ID="CustomerAddressIDTextBox" runat="server" 
            Text='<%# Bind("CustomerAddressID") %>' />
        <br />
        DeliveryAddressID:
        <asp:TextBox ID="DeliveryAddressIDTextBox" runat="server" 
            Text='<%# Bind("DeliveryAddressID") %>' />
        <br />
        Email:
        <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
        <br />
        AltEmail:
        <asp:TextBox ID="AltEmailTextBox" runat="server" 
            Text='<%# Bind("AltEmail") %>' />
        <br />
        AccountNumber:
        <asp:TextBox ID="AccountNumberTextBox" runat="server" 
            Text='<%# Bind("AccountNumber") %>' />
        <br />
        DefaultLocationID:
        <asp:TextBox ID="DefaultLocationIDTextBox" runat="server" 
            Text='<%# Bind("DefaultLocationID") %>' />
        <br />
        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
            CommandName="Update" Text="Update" />
        &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
            CausesValidation="False" CommandName="Cancel" Text="Cancel" />
    </EditItemTemplate>
    <InsertItemTemplate>
        UserId:
        <asp:TextBox ID="UserIdTextBox" runat="server" Text='<%# Bind("UserId") %>' />
        <br />
        CustomerType:
        <asp:TextBox ID="CustomerTypeTextBox" runat="server" 
            Text='<%# Bind("CustomerType") %>' />
        <br />
        CompanyName:
        <asp:TextBox ID="CompanyNameTextBox" runat="server" 
            Text='<%# Bind("CompanyName") %>' />
        <br />
        SunterraNumber:
        <asp:TextBox ID="SunterraNumberTextBox" runat="server" 
            Text='<%# Bind("SunterraNumber") %>' />
        <br />
        SunterraPhone:
        <asp:TextBox ID="SunterraPhoneTextBox" runat="server" 
            Text='<%# Bind("SunterraPhone") %>' />
        <br />
        FirstName:
        <asp:TextBox ID="FirstNameTextBox" runat="server" 
            Text='<%# Bind("FirstName") %>' />
        <br />
        LastName:
        <asp:TextBox ID="LastNameTextBox" runat="server" 
            Text='<%# Bind("LastName") %>' />
        <br />
        ReceivesBirthdayCard:
        <asp:CheckBox ID="ReceivesBirthdayCardCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesBirthdayCard") %>' />
        <br />
        ReceivesNewsletter:
        <asp:CheckBox ID="ReceivesNewsletterCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesNewsletter") %>' />
        <br />
        ReceivesELetter:
        <asp:CheckBox ID="ReceivesELetterCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesELetter") %>' />
        <br />
        RewardPoints:
        <asp:TextBox ID="RewardPointsTextBox" runat="server" 
            Text='<%# Bind("RewardPoints") %>' />
        <br />
        Birthdate:
        <asp:TextBox ID="BirthdateTextBox" runat="server" 
            Text='<%# Bind("Birthdate") %>' />
        <br />
        CustomerAddressID:
        <asp:TextBox ID="CustomerAddressIDTextBox" runat="server" 
            Text='<%# Bind("CustomerAddressID") %>' />
        <br />
        DeliveryAddressID:
        <asp:TextBox ID="DeliveryAddressIDTextBox" runat="server" 
            Text='<%# Bind("DeliveryAddressID") %>' />
        <br />
        Email:
        <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
        <br />
        AltEmail:
        <asp:TextBox ID="AltEmailTextBox" runat="server" 
            Text='<%# Bind("AltEmail") %>' />
        <br />
        AccountNumber:
        <asp:TextBox ID="AccountNumberTextBox" runat="server" 
            Text='<%# Bind("AccountNumber") %>' />
        <br />
        DefaultLocationID:
        <asp:TextBox ID="DefaultLocationIDTextBox" runat="server" 
            Text='<%# Bind("DefaultLocationID") %>' />
        <br />
        IsActive:
        <asp:CheckBox ID="IsActiveCheckBox" runat="server" 
            Checked='<%# Bind("IsActive") %>' />
        <br />
        RowVersion:
        <asp:TextBox ID="RowVersionTextBox" runat="server" 
            Text='<%# Bind("RowVersion") %>' />
        <br />
        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
            CommandName="Insert" Text="Insert" />
        &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
            CausesValidation="False" CommandName="Cancel" Text="Cancel" />
    </InsertItemTemplate>
    <ItemTemplate>
        CustomerID:
        <asp:Label ID="CustomerIDLabel" runat="server" 
            Text='<%# Eval("CustomerID") %>' />
        <br />
        UserId:
        <asp:Label ID="UserIdLabel" runat="server" Text='<%# Bind("UserId") %>' />
        <br />
        CustomerType:
        <asp:Label ID="CustomerTypeLabel" runat="server" 
            Text='<%# Bind("CustomerType") %>' />
        <br />
        CompanyName:
        <asp:Label ID="CompanyNameLabel" runat="server" 
            Text='<%# Bind("CompanyName") %>' />
        <br />
        SunterraNumber:
        <asp:Label ID="SunterraNumberLabel" runat="server" 
            Text='<%# Bind("SunterraNumber") %>' />
        <br />
        SunterraPhone:
        <asp:Label ID="SunterraPhoneLabel" runat="server" 
            Text='<%# Bind("SunterraPhone") %>' />
        <br />
        FirstName:
        <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Bind("FirstName") %>' />
        <br />
        LastName:
        <asp:Label ID="LastNameLabel" runat="server" Text='<%# Bind("LastName") %>' />
        <br />
        ReceivesBirthdayCard:
        <asp:CheckBox ID="ReceivesBirthdayCardCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesBirthdayCard") %>' Enabled="false" />
        <br />
        ReceivesNewsletter:
        <asp:CheckBox ID="ReceivesNewsletterCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesNewsletter") %>' Enabled="false" />
        <br />
        ReceivesELetter:
        <asp:CheckBox ID="ReceivesELetterCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesELetter") %>' Enabled="false" />
        <br />
        RewardPoints:
        <asp:Label ID="RewardPointsLabel" runat="server" 
            Text='<%# Bind("RewardPoints") %>' />
        <br />
        Birthdate:
        <asp:Label ID="BirthdateLabel" runat="server" Text='<%# Bind("Birthdate") %>' />
        <br />
        CustomerAddressID:
        <asp:Label ID="CustomerAddressIDLabel" runat="server" 
            Text='<%# Bind("CustomerAddressID") %>' />
        <br />
        DeliveryAddressID:
        <asp:Label ID="DeliveryAddressIDLabel" runat="server" 
            Text='<%# Bind("DeliveryAddressID") %>' />
        <br />
        Email:
        <asp:Label ID="EmailLabel" runat="server" Text='<%# Bind("Email") %>' />
        <br />
        AltEmail:
        <asp:Label ID="AltEmailLabel" runat="server" Text='<%# Bind("AltEmail") %>' />
        <br />
        AccountNumber:
        <asp:Label ID="AccountNumberLabel" runat="server" 
            Text='<%# Bind("AccountNumber") %>' />
        <br />
        DefaultLocationID:
        <asp:Label ID="DefaultLocationIDLabel" runat="server" 
            Text='<%# Bind("DefaultLocationID") %>' />
        <br />
        IsActive:
        <asp:CheckBox ID="IsActiveCheckBox" runat="server" 
            Checked='<%# Bind("IsActive") %>' Enabled="false" />
        <br />
        RowVersion:
        <asp:Label ID="RowVersionLabel" runat="server" 
            Text='<%# Bind("RowVersion") %>' />
        <br />
    </ItemTemplate>
</asp:FormView>
<llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource21" runat="server" 
    AdapterTypeName="DAL.DatabaseSpecific.DataAccessAdapter, DALDBSpecific" 
    DataContainerType="EntityCollection" 
    EntityFactoryTypeName="DAL.FactoryClasses.CustomerEntityFactory, DAL">
</llblgenpro:LLBLGenProDataSource2>

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 01:46:40   

Specifically, out of these three checboxes:

        ReceivesBirthdayCard:
        <asp:CheckBox ID="ReceivesBirthdayCardCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesBirthdayCard") %>' />
        <br />
        ReceivesNewsletter:
        <asp:CheckBox ID="ReceivesNewsletterCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesNewsletter") %>' />
        <br />
        ReceivesELetter:
        <asp:CheckBox ID="ReceivesELetterCheckBox" runat="server" 
            Checked='<%# Bind("ReceivesELetter") %>' />
        <br />

The "ReceivesELetter" control does not update the database, but the other two work fine. There is nothing wrong with my customer entity as this field updates fine in numerous other places. Same with the database.

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 02:30:52   

The following works perfectly fine -- everything else is EXACTLY the same:

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="custgrid.ascx.vb" Inherits="Sunterra.custgrid" %>
<%@ Register assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" namespace="SD.LLBLGen.Pro.ORMSupportClasses" tagprefix="llblgenpro" %>
<asp:GridView ID="GridView1" runat="server" DataKeyNames="CustomerId" 
    DataSourceID="LLBLGenProDataSource21">
    <Columns>
        <asp:CommandField ShowEditButton="True" />
    </Columns>
</asp:GridView>
<llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource21" runat="server" 
    AdapterTypeName="DAL.DatabaseSpecific.DataAccessAdapter, DALDBSpecific" 
    DataContainerType="EntityCollection" 
    EntityFactoryTypeName="DAL.FactoryClasses.CustomerEntityFactory, DAL">
</llblgenpro:LLBLGenProDataSource2>


When the LLBLGenProDataSource2 is used with LivePersistence, and the ASP.Net controls are auto-generating the columns then the databinding works fine. As soon as I start to specify the columns the whole thing goes pear-shaped, in strange ways.

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 02:42:54   

I'm narrowing this down as much as possible. The markup in the previous message allows me to update all fields in the Customer entity without any problems. I checked the database and the values are getting persisted perfectly.

The ONLY changes I made were:

  1. Remove Autogenerate colums
  2. Hand-enter several columns

The result is the same bizarre behavior. The "ReceivesELetter" column now refuses to persist (it worked fine when in Autogenerate mode). The other two checkboxes work fine. Also the CustomerAddressID column cannot be persisted (it also worked fine in Autogenerate mode).

This is as simple as I can make it. Now I will test this on other machines just in case.

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="custgrid.ascx.vb" Inherits="Sunterra.custgrid" %>
<%@ Register Assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" Namespace="SD.LLBLGen.Pro.ORMSupportClasses"
    TagPrefix="llblgenpro" %>
<asp:GridView ID="GridView1" runat="server" DataKeyNames="CustomerId" AutoGenerateColumns="False"
    DataSourceID="LLBLGenProDataSource21">
    <Columns>
        <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" InsertVisible="False"
            ReadOnly="True" SortExpression="CustomerID" />
        <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
        <asp:BoundField DataField="CustomerAddressID" HeaderText="CustomerAddressID" SortExpression="CustomerAddressID" />
        <asp:CheckBoxField DataField="ReceivesNewsletter" HeaderText="ReceivesNewsletter"
            SortExpression="ReceivesNewsletter" />
        <asp:CheckBoxField DataField="ReceivesELetter" HeaderText="ReceivesELetter" SortExpression="ReceivesELetter" />
        <asp:CommandField ShowEditButton="True" />
    </Columns>
</asp:GridView>
<llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource21" runat="server" AdapterTypeName="DAL.DatabaseSpecific.DataAccessAdapter, DALDBSpecific"
    DataContainerType="EntityCollection" EntityFactoryTypeName="DAL.FactoryClasses.CustomerEntityFactory, DAL">
</llblgenpro:LLBLGenProDataSource2>
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 02:56:09   

Same problem if I disable LivePersistence. I used the examples directly from help file. The same columns do not persist, but the other columns do persist.

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 03:17:22   

Reproduced this error on a different machine. First machine was Win7 x64, second was Win7 x86.

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 04:18:45   

When I create a clean one-page solution with one LLBLgen entity (Customer) from the same database the problem disappears. So tomorrow I will gradually add things back into this new solution until the problem starts again (if it does). Until then this issue is paused.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39862
Joined: 17-Aug-2003
# Posted on: 02-Nov-2009 10:22:51   

this: File version: 2.6.8.624 is the first release, please update the runtimes to the latest build. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 14:50:32   

I updated my runtimes to the latest from the llblgen download page (i.e., reinstalled LLBLgen)

Next I created a stripped-down solution with all the entities I need from the db, and just a single test page. The bug described above STILL happened! I removed all entities except Customer, and now the bug still occurs. Last night I created a test solution with just Customer from the start, and the bug did NOT appear.

I am absolutely stuck at this point. I have to move this project forward but don't know where to look next for this problem.

There is a 512K upload limit. How can I send you the stripped-down solution? It is about 2.5 Mb.

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 15:17:44   

Confirmed again this morning that LLBLgen datasource control is not binding to all of the columns properly when they are specified in the layout. When AutoGenerateColumns = true the bug is absent.

In this markup only the second checkbox persists:


<llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource21" runat="server" 
        AdapterTypeName="DAL.DatabaseSpecific.DataAccessAdapter, DALDBSpecific" 
        DataContainerType="EntityCollection" 
        EntityFactoryTypeName="DAL.FactoryClasses.CustomerEntityFactory, DAL">
    </llblgenpro:LLBLGenProDataSource2>
    <asp:GridView ID="GridView1" runat="server" 
        DataSourceID="LLBLGenProDataSource21" DataKeyNames="CustomerId" 
        AutoGenerateColumns="False">
        <Columns>
                    <asp:CheckBoxField DataField="ReceivesELetter" HeaderText="ReceivesELetter" 
                SortExpression="ReceivesELetter" />
            <asp:CheckBoxField DataField="ReceivesNewsletter" 
                HeaderText="ReceivesNewsletter" SortExpression="ReceivesNewsletter" />

            <asp:CommandField ShowEditButton="True" />
        </Columns>
    </asp:GridView>

When I make the following slight changes then ALL fields persist perfectly, including the checkbox above:

<llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource21" runat="server" 
        AdapterTypeName="DAL.DatabaseSpecific.DataAccessAdapter, DALDBSpecific" 
        DataContainerType="EntityCollection" 
        EntityFactoryTypeName="DAL.FactoryClasses.CustomerEntityFactory, DAL">
    </llblgenpro:LLBLGenProDataSource2>
    <asp:GridView ID="GridView1" runat="server" 
        DataSourceID="LLBLGenProDataSource21" DataKeyNames="CustomerId" 
        AutoGenerateColumns="True">
        <Columns>
            <asp:CommandField ShowEditButton="True" />
        </Columns>
    </asp:GridView>

This is a brand new solution and a brand new LLBLgen project with just the Customer entity selected. The database table is as follows:

USE [SunterraWebDB]
GO

/****** Object:  Table [dbo].[Customer] Script Date: 11/02/2009 10:17:02 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Customer]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Customer](
    [CustomerID] [int] IDENTITY(1,1) NOT NULL,
    [UserId] [uniqueidentifier] NOT NULL,
    [CustomerType] [int] NOT NULL,
    [CompanyName] [varchar](150) NULL,
    [SunterraNumber] [nvarchar](50) NULL,
    [SunterraPhone] [nvarchar](50) NULL,
    [FirstName] [varchar](50) NOT NULL,
    [LastName] [varchar](50) NOT NULL,
    [ReceivesBirthdayCard] [bit] NOT NULL,
    [ReceivesNewsletter] [bit] NOT NULL,
    [ReceivesELetter] [bit] NOT NULL,
    [RewardPoints] [int] NOT NULL,
    [Birthdate] [datetime] NULL,
    [CustomerAddressID] [int] NULL,
    [DeliveryAddressID] [int] NULL,
    [Email] [nvarchar](100) NOT NULL,
    [AltEmail] [nvarchar](100) NULL,
    [AccountNumber] [varchar](50) NULL,
    [DefaultLocationID] [int] NULL,
    [IsActive] [bit] NOT NULL,
    [RowVersion] [timestamp] NOT NULL,
 CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED 
(
    [CustomerID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_Customer] UNIQUE NONCLUSTERED 
(
    [Email] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO

SET ANSI_PADDING OFF
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Address]') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]'))
ALTER TABLE [dbo].[Customer]  WITH CHECK ADD  CONSTRAINT [FK_Customer_Address] FOREIGN KEY([CustomerAddressID])
REFERENCES [dbo].[Address] ([AddressID])
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Address]') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]'))
ALTER TABLE [dbo].[Customer] CHECK CONSTRAINT [FK_Customer_Address]
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Address1]') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]'))
ALTER TABLE [dbo].[Customer]  WITH CHECK ADD  CONSTRAINT [FK_Customer_Address1] FOREIGN KEY([DeliveryAddressID])
REFERENCES [dbo].[Address] ([AddressID])
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Address1]') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]'))
ALTER TABLE [dbo].[Customer] CHECK CONSTRAINT [FK_Customer_Address1]
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Location]') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]'))
ALTER TABLE [dbo].[Customer]  WITH CHECK ADD  CONSTRAINT [FK_Customer_Location] FOREIGN KEY([DefaultLocationID])
REFERENCES [dbo].[Location] ([LocationID])
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Location]') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]'))
ALTER TABLE [dbo].[Customer] CHECK CONSTRAINT [FK_Customer_Location]
GO

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Customer_CustomerTypeID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Customer] ADD  CONSTRAINT [DF_Customer_CustomerTypeID]  DEFAULT ((1)) FOR [CustomerType]
END

GO

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Customer_RecievesBirthdayCard]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Customer] ADD  CONSTRAINT [DF_Customer_RecievesBirthdayCard]  DEFAULT ((0)) FOR [ReceivesBirthdayCard]
END

GO

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Customer_RecievesNewsletter]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Customer] ADD  CONSTRAINT [DF_Customer_RecievesNewsletter]  DEFAULT ((0)) FOR [ReceivesNewsletter]
END

GO

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Customer_RecievesELetter]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Customer] ADD  CONSTRAINT [DF_Customer_RecievesELetter]  DEFAULT ((0)) FOR [ReceivesELetter]
END

GO

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Customer_RewardPoints]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Customer] ADD  CONSTRAINT [DF_Customer_RewardPoints]  DEFAULT ((0)) FOR [RewardPoints]
END

GO

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Customer_IsActive]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Customer] ADD  CONSTRAINT [DF_Customer_IsActive]  DEFAULT ((1)) FOR [IsActive]
END

GO


Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Nov-2009 15:33:24   

Most probably the problem is with the Field names written in the markup for the binding stuff. e.g:

'<%# Bind("DefaultLocationID") %>'

As LLBLGen Generated fields are named with pascal casing, most probably the above should have been:

'<%# Bind("DefaultLocationId") %>'

With small 'd' at the end.

Similar here:

<asp:CheckBoxField DataField="ReceivesELetter" HeaderText="ReceivesELetter" SortExpression="ReceivesELetter" />

Please make the field name used has the same casing as the generated entity field name, not the database column name.

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Nov-2009 18:22:29   

Walaa wrote:

Most probably the problem is with the Field names written in the markup for the binding stuff. e.g:

'<%# Bind("DefaultLocationID") %>'

As LLBLGen Generated fields are named with pascal casing, most probably the above should have been:

'<%# Bind("DefaultLocationId") %>'

With small 'd' at the end.

Similar here:

<asp:CheckBoxField DataField="ReceivesELetter" HeaderText="ReceivesELetter" SortExpression="ReceivesELetter" />

Please make the field name used has the same casing as the generated entity field name, not the database column name.

Walaa you saved the day!!!

That is exactly what it was. There were no exceptions anywhere so I never thought of that.

The problem was that I was using a SQL datasource in order to get a list of bound columns, then pasting that into the markup instead of hand-entering each column manually. Is there any way to get behavior like that from the LLBLgen datasource? I.e., have the bound control generate the templates like it does with SQL datasource?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 03-Nov-2009 10:29:24   

If you place an LLBLGenDataSource to a webForm, and configure it. Then you place a GridView for example and then bind it to the LLBLGenDataSource,columns will be generated automatically for you. (metadata read from the dataSource).

Similar behaviour will hapen if you bind the GridView to none, and then re-bind it to the LLBLGenDataSource.

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 03-Nov-2009 13:29:53   

Walaa wrote:

If you place an LLBLGenDataSource to a webForm, and configure it. Then you place a GridView for example and then bind it to the LLBLGenDataSource,columns will be generated automatically for you. (metadata read from the dataSource).

Similar behaviour will hapen if you bind the GridView to none, and then re-bind it to the LLBLGenDataSource.

Is that only for typedlists/typedviews? I'm binding to an entitycollection in this case and I don't get the generated columns no matter what I do...

Maybe you can tell me what I am doing wrong:

  1. Drop an LLBLgen DataSource2 control on the form.
  2. Use the control's menu to configure for a simple Customers Typed List
  3. Drop a GridView on the form.
  4. Use the GridView's menu to set the datasourceid to the LLBL control

Result: no columns are generated in the template as they are with a SQL datasource...

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Nov-2009 02:21:08   

So, you are binding to a entitycollection. Make sure the LLBLGenProDataSource2 livepersistenceinfo is true, and gridview autogeneratecolumns is true as well. Please post the declarative aspx of this test.

David Elizondo | LLBLGen Support Team
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 04-Nov-2009 20:31:53   

daelmo wrote:

So, you are binding to a entitycollection. Make sure the LLBLGenProDataSource2 livepersistenceinfo is true, and gridview autogeneratecolumns is true as well. Please post the declarative aspx of this test.

Here is a basic example. The Datasource/Gridview never generates column information no matter what I do.

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucOrderDetails.ascx.vb" Inherits="Sunterra.ucOrderDetails" %>
<%@ Register assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" namespace="SD.LLBLGen.Pro.ORMSupportClasses" tagprefix="llblgenpro" %>
<llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource21" runat="server" 
    AdapterTypeName="DAL.DatabaseSpecific.DataAccessAdapter, DALDBSpecific" 
    DataContainerType="EntityCollection" 
    EntityFactoryTypeName="DAL.FactoryClasses.OrderEntityFactory, DAL">
</llblgenpro:LLBLGenProDataSource2>
<asp:GridView ID="GridView1" runat="server" 
    DataSourceID="LLBLGenProDataSource21">
</asp:GridView>

The columns are generated for Typed Lists however (occasionally, not always).

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Nov-2009 04:46:48   

The code looks ok. Must be something around your code. There is generated code when you load the page where the grid resides?

David Elizondo | LLBLGen Support Team
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 05-Nov-2009 14:06:56   

daelmo wrote:

The code looks ok. Must be something around your code. There is generated code when you load the page where the grid resides?

I'm not sure what you mean by generated code...

I observed behavior yesterday whereby:

  • create a fresh web form
  • drop llbl datasource and configure
  • drop gridview and set datasource
  • works -- cols generated.

Next:

  • completely remove the markup for the datasource and grid from that form
  • add the controls back in again
  • doesn't work - no cols this time

Strange!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-Nov-2009 02:24:12   

csmac3144 wrote:

daelmo wrote:

The code looks ok. Must be something around your code. There is generated code when you load the page where the grid resides?

I'm not sure what you mean by generated code...

My bad, I meant "generated sql".

csmac3144 wrote:

I observed behavior yesterday whereby:

  • create a fresh web form
  • drop llbl datasource and configure
  • drop gridview and set datasource
  • works -- cols generated.

Next:

  • completely remove the markup for the datasource and grid from that form
  • add the controls back in again
  • doesn't work - no cols this time

Strange!

Weird. I can't reproduce that. It might be something on Visual Studio, or maybe you didn't choose the EntityCollectionTypeName. Anyway you can code the columns manually via Columns and BoundFields.

David Elizondo | LLBLGen Support Team