Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...How to get Edited values for a custom module?How to get Edited values for a custom module?
Previous
 
Next
New Post
11/2/2009 11:46 AM
 

I have a major problem and unfortunately I just cannot find any answers. Please help. I am at my wit's end.

I have a custom module that does something very simple: it edits the values of a single record from a database table via Linq to Sql. I have created an edit form and I can add a new entity just fine; all the values of the fields on the page are grabbed, stuffed into the entity and saved correctly. The method for adding looks like this: 

 protected void Add_Click(object sender, EventArgs e)
        {
            MyDataContext db = new MyDataContext ();

               var doc = new MyDocument();
                doc.ModuleId = ModuleId;
                doc.Header = _header.Text;
                doc.URL = _url.Text;


                db.MyDataContext .InsertOnSubmit(doc);
                db.SubmitChanges();
            db.Dispose();

            Response.Redirect(Globals.NavigateURL(), true);
        }

This works for insertion just fine.

What does not work is updating any of the values. The update method looks basically the same, except I query for the entity first. Then I try and copy the values from the fields on the page. Only the fields don't contain the new data! I decided to use Response.Write to actually write out the values of the text fields on the page, and they are not printing out the newly edited values. The old values are getting printed out. Which tells me that for some reason the new values are not getting back to me. Now, it's been a while since I did anything in asp.net, so please, someone help me out here. This shouldn't be this hard.

 

 
New Post
11/2/2009 11:53 AM
 

 Make sure you are not rebinding the items on page load.  Page load runs every time (before the button click event is fired) and if you call a bind on load without wrapping it in an if to check if it is a postback, it will simply rebuild the old data and all your changes are over written.  

Examle on how to handle in the Onload Event

if(! Page.IsPostBack) {

LoadModuleData();

}


Best Regards,

Robert J Collins | Co-Founder & President

Netlogic Corporation

 
New Post
11/2/2009 11:58 AM
 

Thanks Robert. That was it.

 
New Post
11/2/2009 2:53 PM
 

Good to hear.  Post back if you have any more trouble. 


Best Regards,

Robert J Collins | Co-Founder & President

Netlogic Corporation

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...How to get Edited values for a custom module?How to get Edited values for a custom module?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out