llbgenlDataSource problem

Posts   
 
    
Posts: 5
Joined: 08-Aug-2007
# Posted on: 08-Aug-2007 18:42:18   

Hi ,

I am new in LLlgen.

i have a query which use 3-4 table in my database with joins.Normaly i put all in sqlDataSource object in .net and i use this fields like databound in aspx page with Eval 's . And i use gridview's template property easly with sqlDataSource. Question : how am i make this structure with llblgenDataSource ? i dont want to DataTable resultSet ,and i dont want to use LLbl Gui because i generated my codes. i want to 3-4 table fields in gridview in design time with llblGenDataSource like SqlDataSource.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Aug-2007 18:54:38   

Hi time-to-trace ( hehe wink ) Simply use _LLBLGenProDataSource _as you use SQLDataSource, as LLBLGenProDataSource inherits from System.Web.UI.DataSourceControl as well.

David Elizondo | LLBLGen Support Team
Posts: 5
Joined: 08-Aug-2007
# Posted on: 08-Aug-2007 19:12:44   

yes i believe that LLBLGenProDataSource make it but how ? simple_smile

ok assume that i have a query :

SELECT p.ProductID, p.ProductName, p.QuantityPerUnit, p.UnitPrice, p.UnitsInStock, p.Discontinued, c.CategoryName, o.ShipName FROM [Products] p join [Categories] c on p.CategoryID = c.CategoryID join [OrderDetail] d on p.ProductID=d.ProductID join [Order] o on d.OrderID=o.OrderID where p.SupplierID =@SupplierID and o.ShipCountry=@Country

i want to design in gridview template column this results.In sqldatasource , i write this query in selectparameter , but llbgenprodatasource how make it ? if u show me a little example i am very pleasure simple_smile

thank u .

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Aug-2007 19:20:25   

Here is a very simple example that populates 2-way GridView databinding a collection of CustomerEntity via LLBLGenDataSource2.

As I'm using LivePersistence="True" I don't need to use behind code. I put here de ASPX declarative:

<llblgenpro:llblgenprodatasource2 id="_customerDS" runat="server" adaptertypename="Northwind.DatabaseSpecific.DataAccessAdapter, NorthwindDBSpecific"
    datacontainertype="EntityCollection" entityfactorytypename="Northwind.FactoryClasses.CustomersEntityFactory, Northwind"
    livepersistence="True" OnPerformSelect="_customerDS_PerformSelect" OnPerformWork="_customerDS_PerformWork">
</llblgenpro:llblgenprodatasource2>

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerId" DataSourceID="_customerDS">
    <Columns>
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
        <asp:BoundField DataField="CustomerId" HeaderText="CustomerId" ReadOnly="True" SortExpression="CustomerId" />
        <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" />
        <asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" />
        <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle" />
        <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
        <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
        <asp:BoundField DataField="Region" HeaderText="Region" SortExpression="Region" />
        <asp:BoundField DataField="PostalCode" HeaderText="PostalCode" SortExpression="PostalCode" />
        <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
        <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
        <asp:BoundField DataField="Fax" HeaderText="Fax" SortExpression="Fax" />
    </Columns>
</asp:GridView>
</form>

For more detail explanation please read LLBLGenPro Help - Using generated code - Adapter - Databinding at design time and runtime - Databinding with ASP.NET 2.0.

Hope helpful

David Elizondo | LLBLGen Support Team
Posts: 5
Joined: 08-Aug-2007
# Posted on: 08-Aug-2007 21:53:54   

but u dont understand me rage

i have a query which i wrote above. this query return a resultset and this resultset have some columns in 3-4 table .for example Order -> orderdate , customer->customerName etc.. in this case how am i use llbgenldatasource with gridview. please write which send my messages. i try it but no execute. if u have any idea any alternatife , i wait your opinions.

thank u.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 09-Aug-2007 11:01:02   

timetotrace wrote:

but u dont understand me rage

i have a query which i wrote above. this query return a resultset and this resultset have some columns in 3-4 table .for example Order -> orderdate , customer->customerName etc.. in this case how am i use llbgenldatasource with gridview. please write which send my messages. i try it but no execute. if u have any idea any alternatife , i wait your opinions.

thank u.

Your query is a readonly list, so either you create a typedlist in llblgen pro's designer and you can use it with the llblgenprodatasource controls, or you create a dynamic list in the code behind page of your page and you bind the datatable you fetch the data into directly to the grid.

You see, a datasource control is only useful for writable data, as the datasourcecontrol is used for 2-way databinding. However this is a readonly list, so just fetch it and bind it to the grid.

If you want more convenience, create a typed list in the designer, generate code and point the llblgenprodatasource control to the typedlist.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 5
Joined: 08-Aug-2007
# Posted on: 10-Aug-2007 15:28:35   

thank u simple_smile