LLBLDataSource2 and FormView

Posts   
 
    
Posts: 35
Joined: 10-Sep-2006
# Posted on: 19-Dec-2006 04:15:19   

Ok - first let me qualify this as I'm a big code behind guy and I'm just trying out using datasource control s to see how they work. Ok I have a gridview on a page that is bound via an LLBLDataSource2 (I'm using adapter). I also have an edit template setup. I can fetch and bind to the grid just fine. I can edit a row and have the changes go to the database and the grid refreshes itself with the edited values.

I want to add insert functionality. So I coded a div on the page which I pop up and let the users enter new data in. It as asp:form and I have it bound to the same LLBLdatasource as the gridview. When I enter in all the info and hit insert - the new row is inserted into the database. BUT - and here is where I'm stuck my grid is not getting refreshed. I but in break points and the page is refreshing.

What do I need to do to get the gridview to refresh with the new row that was just inserted. I"m not sure when the new row acutally get inserted into the db. On the page load event of the page I put a break and check the db and the row is not inserted yet - I run through the rest of the page load and when done the row is in the db. Is there some even that the datasource raises that I can force a gridview refresh or rebind?


        <llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource2_1" runat="server"  AdapterTypeName="Mega.Review.DatabaseSpecific.DataAccessAdapter, Mega.ReviewDBSpecific" 
            DataContainerType="EntityCollection"  EntityFactoryTypeName="Mega.Review.FactoryClasses.EmployeeEntityFactory, Mega.Review">
        </llblgenpro:LLBLGenProDataSource2>


Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Dec-2006 08:32:17   

In the FormView OnItemInserted event do the following:


LLBLGenProDataSource2_1.Refetch = true;
GridView1.DataBind();

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 19-Dec-2006 10:06:05   

or, bind the same llblgenprodatasource control to the grid as to the formview. See for examples the Hnd sourcecode, admin forms (ip bans for example) http://www.llblgen.com/hnd

Frans Bouma | Lead developer LLBLGen Pro