Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Databind to a TypedView filled from stored procedure
 

Pages: 1
LLBLGen Pro Runtime Framework
Databind to a TypedView filled from stored procedure
Page:1/1 

  Print all messages in this thread  
Poster Message
raist
User



Location:
Madrid, Spain
Joined on:
19-Apr-2010 23:57:10
Posted:
114 posts
# Posted on: 30-May-2011 21:05:48.  
Hi,
We have a parameter-based stored procedure that returns a resultset we have mapped to a TypedView.
Therefore we can fill the TypedView as in the documentation...

Code:
CustomersOnCountryTypedView customersTv = new CustomersOnCountryTypedView()
// Fill the TypedView with a class method that internally calls the stored procedure
customersTv.Fill(null, "USA");


... but we'd like to view it in a web grid. How can we bind that TypedView to a LLBLGenProDataSource (or LLBLGenProDataSource2)?

The code from the fill method is something like
Code:
public bool Fill(ITransaction transactionToUse, System.String countryID)
        {
            bool toReturn;
            using(IRetrievalQuery query = RetrievalProcedures.GetQueryForCustomersOnCountryTypedView(countryID))
            {
                toReturn = new TypedListDAO().GetMultiAsDataTable(GetFields(), this, query, transactionToUse);
            }
            return toReturn;
        }


We tried some explicit cast with ITypedView, but it didn't work.

It should be really simple, but we don't get it right. Confused

TIA
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8110 posts
# Posted on: 31-May-2011 07:18:21.  
You will have to use LLBLGenProDataSource and intercept activity. So, implement the PerformSelect event handler and there you can fill your view and map it to the data source.

If you need further assistance on this please let us know.


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
raist
User



Location:
Madrid, Spain
Joined on:
19-Apr-2010 23:57:10
Posted:
114 posts
# Posted on: 31-May-2011 12:21:24.  
Thanks for your help Daelmo.
We tried before to implement the event handler.

The problem is that CustomersOnCountryTypedView doesn't implement ITypedView. So, whatever we do, we get a cast error (we cannot pass the "USA" parameter to e.ContainedTypedView.Fill(...)

We've tried (again) to implement the event handler passing the SP resultset directly to the GridView. No luck so far:

Code:
protected void customersDS_PerformSelect(object sender, PerformSelectEventArgs e)
    {
        DataTable dc = RetrievalProcedures.SpCustomersOnCountry("USA");
        theGrid.DataSource = dc;                    
    }

  Top
raist
User



Location:
Madrid, Spain
Joined on:
19-Apr-2010 23:57:10
Posted:
114 posts
# Posted on: 31-May-2011 12:52:46.  
Solved, but a little bit aesthetic Dissapointed
- No llblgenprodatasource databinding, therefore, no TypedView used (only the SP call)

Code:
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DataTable dc = RetrievalProcedures.SpCustomersOnCountry("USA");
            theGrid.DataSource = dc;
            theGrid.DataBind();
        }
    }


Is there a better way?


  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14585 posts
# Posted on: 31-May-2011 13:55:30.  
TypedViews made from SP's resultSets don't implement ITYedView indeed.

You can implement the interface if you want.
The trick is that most SPs take parameters, while ITypedView has a fill method with no parameters.

So you will need to have properties to set these parameters, or maybe in a CTor and then implement the ITypedView.Fill() method, which passes these parameters to the already existing Fill() mehod with parameters.

Also you will need to implement count and GetDbCount().

But I don't see a point for all this, unless you want to use LLBLGenProDataSource, for design time databinding.
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.