FormView - Display Inserted row

Posts   
 
    
chrisong
User
Posts: 3
Joined: 16-May-2007
# Posted on: 25-May-2007 09:32:49   

Hello,

I'm using LLBLGenProDataSource with FormView to insert/edit/delete/view data. I've enabled paging on my FormView. The default behavior of FormView is that when a new record is inserted, it is not shown if there is already a record in the table.

I'm aware that I can use the PageIndex property of FormView to set the page to the newly inserted record. Example.


protected void frmvDependentChildren_ItemInserted(object sender, FormViewInsertedEventArgs e)
   {
      if (e.AffectedRows == 1)
      {
          frmvDependentChildren.PageIndex = Convert.ToInt32(frmvDependentChildren.DataKey.Value.ToString());
      }
   }

But this result in a Null exception error. I could 'cheat' by setting PageIndex to some large magic number like 999999 and it will work.

Can I get LLBLGenProDataSource to return the Identity of the inserted record?

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 25-May-2007 09:42:04   

Can I get LLBLGenProDataSource to return the Identity of the inserted record?

You can do that by handling the Insert yourself, by setting LivePersistence to false. Please check the following example: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8529&StartAtMessage=25&#47707