LLBLGenProDataSource2 compared with ObjectDataSource

Posts   
 
    
yowl
User
Posts: 271
Joined: 11-Feb-2008
# Posted on: 31-Oct-2008 00:30:54   

I am trying to replace my ObjectDataSoure with LLBLGenProDataSource2, and I've hit a difference which I'm not sure how to work around:

I have a GridView and a DetailsView both bound to the same data source (either an ObjectDataSource or LLBLGenProDataSource2). The DetailsView allows inserts, and when using the ObjectDataSource, the GridView is automatically updated after the insert to reflect the new row whereas with the LLBLGenProDataSource2 this does not happen. Is this by design and if so how can I tell the grid it needs to reload (LLBLGenProDataSource2 .Refetch is already = true in the DetailView.ItemInserted event)?

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="MaintainCourses.aspx.cs" Inherits="MaintainCourses" Title="Untitled Page" %>

<%@ Register Assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" Namespace="SD.LLBLGen.Pro.ORMSupportClasses" TagPrefix="llblgenpro" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <aspsmile ropDownList ID="DropDownList1" runat="server" AutoPostBack="True"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </aspsmile ropDownList> <br /> <br /> <div class="todoheader"> Courses </div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" CssClass="gridview" AlternatingRowStyle-CssClass="even" GridLines="None" DataKeyNames="Id" DataSourceID="ObjectDataSource1" Width="328px" > <Columns> <asp:CommandField ShowSelectButton="True" ShowEditButton="True" /> <asp:BoundField DataField="Id" ReadOnly="True" SortExpression="Id" /> <asp:BoundField DataField="CategoryId" HeaderText="Category" SortExpression="CategoryId" /> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> </Columns> <AlternatingRowStyle CssClass="even" /> </asp:GridView> <div class="insertheader"> Add a new course </div> <aspsmile etailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="ObjectDataSource1" DefaultMode="Insert" CssClass="detailsview" GridLines="None"> <Fields> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> <asp:BoundField DataField="CategoryId" HeaderText="Category" SortExpression="CategoryId" /> <asp:CommandField ShowInsertButton="True" /> </Fields> </aspsmile etailsView> <llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource1" runat="server" AdapterTypeName="em.DatabaseSpecific.DataAccessAdapter, emDBSpecific" DataContainerType="EntityCollection" EntityFactoryTypeName="em.FactoryClasses.CourseEntityFactory, em" > <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="CategoryId" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </llblgenpro:LLBLGenProDataSource2> <aspfrowning bjectDataSource ID="ObjectDataSource1" runat="server" DataObjectTypeName="em.EntityClasses.CourseEntity" InsertMethod="Insert" SelectMethod="FetchByCategoryId" TypeName="xxx.CourseService" UpdateMethod="Insert"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="CategoryId" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </aspfrowning bjectDataSource> </asp:Content>

yowl
User
Posts: 271
Joined: 11-Feb-2008
# Posted on: 31-Oct-2008 00:35:58   

Few more details:

Postgres DQE 2.6.8.81 ORMSupportClasses v2.6.8.1013

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-Oct-2008 06:24:46   

Hi yowl, Could you please post the declarative ASPX and relevant code-behind test using LLBLGenProDataSource2? (as far as I see, you only pasted the ObjectDataSourceTest)

This is the way LLBLGenProDataSource2 works.

David Elizondo | LLBLGen Support Team
yowl
User
Posts: 271
Joined: 11-Feb-2008
# Posted on: 31-Oct-2008 08:52:10   

Sorry, I should have said to switch between the 2 datasources, use the same ASPX but copy paste the llblgendatasource2 id into the gridview and detailsview tags to replace the objectdatasource id.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 31-Oct-2008 10:39:50   

When you update the DetailsView you should call the GridView.DataBind(); to refresh the dataGrid.

Please check the Employees.aspx page (and its code behind) of the "ASP.NET 2.0 databinding example" example project posted in the downloads section of llblgen.com.