Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> LLBLGenDataSource and Inserts
 

Pages: 1
LLBLGen Pro Runtime Framework
LLBLGenDataSource and Inserts
Page:1/1 

  Print all messages in this thread  
Poster Message
MattWoberts
User



Location:
Lancaster, UK
Joined on:
08-Apr-2004 10:24:31
Posted:
497 posts
# Posted on: 15-Jun-2007 16:31:48.  
Hi all,

I'm trying to use the GridView to do an insert, and not sure what I need to do.. I don't work much with ASP.NET controls, so I'm a little confused at it... Heres what I have done

1) Added an LLBLGenDataSource2 control, no worries there.
2) Bound it to a GridView. Ok, now I can delete and edit. Great.
3) I allow my gridview's command button to show an insert. Hmmm, that doesnt't seem to change anything. So I create a template for the insert that calls a method "AddNewRow"..

Here's where I'm stuck. What do I do now? I just want to add a new blank row for insertion, but the grivdiew doesn't seem to do anything

I have so far added this (kludgey?) code to the AddNewRow method:

Code:
        protected void AddNewRow(object sender, EventArgs e)
        {

            // I'm going to add my own row to the database (probably stupid idea!)
            CandidateEntity candidate = new CandidateEntity();
            candidate.Name = "";
            candidate.Username = "user";
            candidate.Password = "password";
            UserManager userManager = new UserManager();
            userManager.AddUser(candidate);

         // Darn, nothing happens when I call this code, so I'll try this...
            GridView1.DataBind(); // This doesn't do anything either
        }



As I have it now, it adds a new row to the DB but doesn't reflect in the gridview until I F5 the page! ITs probably dead easy to do this, please, someone put me out of my misery!


Thanks!

And have a good weekend everyone!
Matt  Top
jmeckley
User



Location:
Harrisburg, PA, USA
Joined on:
05-Jul-2006 16:03:19
Posted:
403 posts
# Posted on: 15-Jun-2007 18:56:59.  
if your using a LLBLDataSource you can do this
Code:
protected void AddNewRow(object sender, EventArgs e)
{
     // I'm going to add my own row to the database (probably stupid idea!)
     CandidateEntity candidate = new CandidateEntity();
     candidate.Name = "";
     candidate.Username = "user";
     candidate.Password = "password";
     UserManager userManager = new UserManager();
     userManager.AddUser(candidate);

     [DataSource].Refetch = true;
}

if not you need to manually refetch the data
Code:
protected void AddNewRow(object sender, EventArgs e)
{
     // I'm going to add my own row to the database (probably stupid idea!)
     CandidateEntity candidate = new CandidateEntity();
     candidate.Name = "";
     candidate.Username = "user";
     candidate.Password = "password";
     UserManager userManager = new UserManager();
     userManager.AddUser(candidate);

    GridView1.DataSource = userManager.GetUsers();
    GridView1.DataBind();
}


Jason Meckley
Programmer
 
Top
MattWoberts
User



Location:
Lancaster, UK
Joined on:
08-Apr-2004 10:24:31
Posted:
497 posts
# Posted on: 18-Jun-2007 14:46:08.  
I shall try that and see if it works, it looks promising though Wink
Matt  Top
Pages: 1  


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

Version: 2.1.12172008 Final.