click on "Save" button not picking up changes on form

Posted on 2013-01-14
Medium Priority
Last Modified: 2013-01-14
I am guessing this is something simple.  I've not done any ASP.NET programming in about 9 months, so I am a little rusty.

Basically, I have a bunch of fields and drop down lists on a form that I am filling.  Then I can make changes to some of the values.  Then I want to save those changes.

The problem is when I go to save the changes, the changes are not getting picked-up.  According to the values of each control, they are the same as they were when the form first loaded the values.  It's as if I have made no changes, but I know I have.

Here is my code and markup:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.IO;
using System.Data.Linq;
using System.Data;

using Models;
using Framework.Business;
using Framework.Utilities;
using System.Xml.Linq;
using Framework.UIControls.Base;
using System.Configuration;
using System.Text;
using System.Data.OleDb;
using System.Data.Common;
using System.Threading;

namespace Reo.ContentControls
    //page created by Tom Knowlton - cr 1123

    public partial class AgentFormEdit : Reo.Base.BaseControl
        private List<Models.AgentFormEdit_AgentForm_GetResult> getOneAgentForm;

        protected List<Models.AgentFormAdd_AgentFormTypes_SelectResult> showamfclientagentforms;

        protected void Page_Load(object sender, EventArgs e)

//        private void FillTaskCodeDropDown()
//        {
////            SELECT t.code      
////from Task t
////where t.CategoryID in (935,930)
//        }

        private void FillAgentFormFields()
            string[] aflidsid = Session["afa_agentformlistidsid"].ToString().Split('-');
            using (AgentFormsDataContext dc = new AgentFormsDataContext())
                getOneAgentForm = dc.AgentFormEdit_AgentForm_Get(Convert.ToInt32(aflidsid[0]), Convert.ToInt32(aflidsid[1])).ToList<Models.AgentFormEdit_AgentForm_GetResult>();                

            foreach (Models.AgentFormEdit_AgentForm_GetResult agentfield in getOneAgentForm)
                ddlLookupFormType.LookupID = agentfield.FormTypeID;
                TextBoxSequence.Text = agentfield.Sequence.ToString();
                TextBoxFormName.Text = agentfield.FormName;
                TextBoxColist.Text = agentfield.ColistFlag.ToString();
                RadioButtonAcceptanceRequiredFalse.Checked = agentfield.AcceptanceReqd == true ?  false : true;
                RadioButtonAcceptanceRequiredTrue.Checked = !RadioButtonAcceptanceRequiredFalse.Checked;
                RadioButtonDuplicatesAllowedFalse.Checked = agentfield.DuplicatesAllowed == true ? false : true;
                RadioButtonDuplicatesAllowedTrue.Checked = !RadioButtonDuplicatesAllowedFalse.Checked;                
                TextBoxExternalLink.Text = agentfield.ExternalLink;
                TextBoxTaskCode.Text = agentfield.TaskCode;
             //   TextBoxAMFirm.Text = agentfield.AMFID.ToString();
             //   TextBoxClient.Text = agentfield.ClientID.ToString();
                ddlProducts.SelectedValue = agentfield.ProductID.ToString();
                RadioButtonActiveFalse.Checked = agentfield.Active == true ? false : true;
                RadioButtonActiveTrue.Checked = !RadioButtonActiveFalse.Checked;

                //ternary operator syntax example
                //int ystep = y0 < y1 ? 1 : -1;

        private void FillProductTypeDDL()
            ProductTypeDataContext pdc = new ProductTypeDataContext();
            var result = pdc.ProductType_DropDown_Get(null, null, CurrentUser.UserID, CurrentUser.UserSID).ToList();
            this.ddlProducts.DataSource = result;
            ddlProducts.DataTextField = "Name";
            ddlProducts.DataValueField = "ProductTypeID";

        protected void ButtonSave_Click(object sender, EventArgs e)
            Session["afa_returnfromchild"] = true;
            string prevPage = Session["afa_parent"].ToString();

        private void SaveChanges()
            using (AgentFormsDataContext dc = new AgentFormsDataContext())
                string[] aflidsid = Session["afa_agentformlistidsid"].ToString().Split('-');

                int agentformlistid = Convert.ToInt32(aflidsid[0]);
                int agentformlistsid = Convert.ToInt32(aflidsid[1]);
                int formtypeid = Convert.ToInt32(ddlLookupFormType.LookupID);
                int sequence = Convert.ToInt32(TextBoxSequence.Text);
                string formname = TextBoxFormName.Text;
                int colist = Convert.ToInt32(TextBoxColist.Text);
                bool rbAcceptReqd = RadioButtonAcceptanceRequiredFalse.Checked == true ? false : true;
                bool rbDupAllowed = RadioButtonDuplicatesAllowedFalse.Checked == true ? false : true;
                string extlink = TextBoxExternalLink.Text;
                string taskCode = TextBoxTaskCode.Text;
                int productid = Convert.ToInt32(ddlProducts.SelectedValue);
                bool rbActive = RadioButtonActiveFalse.Checked == true ? false : true;

                dc.AgentFormEdit_AgentForm_Update(agentformlistid, agentformlistsid, formtypeid, sequence, formname, colist, rbAcceptReqd, rbDupAllowed, extlink, taskCode, productid, rbActive);

                //dc.AgentFormEdit_AgentForm_Update(Convert.ToInt32(aflidsid[0]), Convert.ToInt32(aflidsid[1])).ToList<Models.AgentFormEdit_AgentForm_GetResult>();
                //dc.AgentFormEdit_AgentForm_Update(Convert.ToInt32(aflidsid[0]), Convert.ToInt32(aflidsid[1])).ToList<Models.AgentFormEdit_AgentForm_GetResult>();

        protected void ButtonCancel_Click(object sender, EventArgs e)
            Session["afa_returnfromchild"] = true;
            string prevPage = Session["afa_parent"].ToString();


Open in new window

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AgentFormEdit.ascx.cs" Inherits="Reo.ContentControls.AgentFormEdit" %>
<%@ Register Assembly="Framework" Namespace="Framework.UIControls" TagPrefix="cc1" %>

<%--page created by Tom Knowlton - cr 1123--%>

<script type="text/javascript" src="Scripts/jQueryDatePicker/jquery-ui-1.8.5.custom.min.js"></script>

<script type="text/javascript">

     $(document).ready(function () {
         $('div[id="agentformfields"]').css('position', 'relative');
         //$('div[id="agentformfields"]').css('background-color', 'red');
         $('div[id="agentformfields"]').css('height', '500px');
         $('div[id="agentformfields"]').css('width', '800px');

         $('div[class="afa_label"]').css('position', 'relative');
         $('div[class="afa_label"]').css('width', '120px');
      //   $('div[class="afa_label"]').css('background-color', 'red');
         $('div[class="afa_label"]').css('float', 'left');
         $('div[class="afa_label"]').css('clear', 'left');
         $('div[class="afa_label"]').css('text-align', 'right');
         $('div[class="afa_label"]').css('margin-right', '5px');
         $('div[class="afa_label"]').css('padding-top', '5px');

         $('div[class="afa_control"]').css('position', 'relative');
         $('div[class="afa_control"]').css('width', '280px');      
         $('div[class="afa_control"]').css('float', 'left'); 
         $('input').css('width', '30px');
         $('input[name*="TextBoxExternalLink"]').css('width', '200px');
         $('input[name*="TextBoxFormName"]').css('width', '200px');
         $('select[name*="TextBoxExternalLink"]').css('width', '200px');

         $('div[class="afa_controlrb"]').css('position', 'relative');
         $('div[class="afa_controlrb"]').css('width', '80px');
         $('div[class="afa_controlrb"]').css('float', 'left');

         $('div[class="afa_button"]').css('position', 'relative');
         $('div[class="afa_button"]').css('width', '150px');
         $('div[class="afa_button"]').css('float', 'left');

         $('input[type="submit"]').css('width', '80px');
         $('input[type="submit"]').css('position', 'relative');
         $('input[type="submit"]').css('float', 'left');       



<div id="frame">
    <div id="frame_header">
        <div id="frame_title">
                Edit Agent Form</h1>

   <%-- <asp:UpdatePanel ID="UpdatePanelAgentFormAdd" runat="server" 
    <div id="corpus">
        <div id = "agentformfields">
                <div id="formtype" class="afa_label">Form Type</div>
                <div id="formtypeddl" class="afa_control"><cc1:DdlLookup runat="server" HeaderCode="DocType" ID="ddlLookupFormType"></cc1:DdlLookup></div>
                <div id="sequence" class="afa_label">Sequence</div>
                <div id="tbsequence" class="afa_control"><asp:TextBox ID="TextBoxSequence" runat="server"></asp:TextBox></div>
                <div id="formname" class="afa_label">Form Name</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxFormName" runat="server"></asp:TextBox></div>
                <div id="colist" class="afa_label">Colist</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxColist" runat="server"></asp:TextBox></div>
                <div id="accptreqd" class="afa_label">Acceptance Reqd</div>
                <div class="afa_controlrb" id="radiobuttonaccptreqdtrue"><asp:RadioButton ID="RadioButtonAcceptanceRequiredTrue" GroupName="AccReqdGroup" runat="server" Text="True" /></div>
                <div id="radiobuttonaccptreqdfalse" class="afa_controlrb"><asp:RadioButton ID="RadioButtonAcceptanceRequiredFalse"  GroupName="AccReqdGroup" runat="server" Text="False"/></div>
                <div id="dupallow" class="afa_label">Duplicates Allowed</div>
                <div class="afa_controlrb" id="radiobuttondupallowedtrue"><asp:RadioButton ID="RadioButtonDuplicatesAllowedTrue" GroupName="DupAllowedGroup" runat="server" Text="True" /></div>
                <div id="radiobuttondupallowedfalse" class="afa_controlrb"><asp:RadioButton ID="RadioButtonDuplicatesAllowedFalse"  GroupName="DupAllowedGroup" runat="server" Text="False"/></div>
                <div id="extlink" class="afa_label">External Link</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxExternalLink" runat="server"></asp:TextBox></div>
                <div id="taskcode" class="afa_label">Task Code</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxTaskCode" runat="server"></asp:TextBox></div>
                <div id="amfirm" class="afa_label">AM firm</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxAMFirm" runat="server"></asp:TextBox></div>
                <div id="client" class="afa_label">Client</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxClient" runat="server"></asp:TextBox></div>                
                <div id="product" class="afa_label">Product</div>
                <div class="afa_control"><asp:DropDownList ID="ddlProducts" runat="server"></asp:DropDownList></div>
                <div id="active" class="afa_label">Active</div>
                <div id="radiobuttonacttrue" class="afa_controlrb"><asp:RadioButton ID="RadioButtonActiveTrue" GroupName="ActiveGroup" runat="server" Text="True" /></div>
                <div id="radiobuttonactfalse" class="afa_controlrb"><asp:RadioButton ID="RadioButtonActiveFalse"  GroupName="ActiveGroup" runat="server" Text="False"/></div>
                <div id="Div2" class="afa_label"> </div>                
                <div id="Div3" class="afa_label"> </div>                
                <div id="Div1" class="afa_label"></div>
                <div id="divsave" ><asp:Button runat="server" ID="ButtonSave" Text="Save" 
                        Width="100px" onclick="ButtonSave_Click" /></div>
                <div id="divcancel"><asp:Button runat="server" ID="ButtonCancel" Text="Cancel" 
                        Width="100px" onclick="ButtonCancel_Click" /></div>
 <%--   </ContentTemplate>
    <div id="footer"></div>
<div id="end_cap"></div>

Open in new window

Question by:Tom Knowlton

Accepted Solution

rpkhare earned 2000 total points
ID: 38775204
I think you need to use:

       protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)

Open in new window


Author Comment

by:Tom Knowlton
ID: 38775300

Once I finally got a hold of my boss, he made the same suggestion.

Great minds think alike, right?

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web conte…
Through the video, you can check the migration process of Outlook PST file to PDF. Kernel for Outlook to PDF tool can convert Outlook emails with all attributes like Subject, To, From, Cc, Bcc and other folders such as Inbox, Outbox, Sent Items, Jun…
Wrapper-1-Query. Use an Excel function to calculate a column for an Access query. Part 1. Shows a query in Access that has a calculated column with the results of an Excel worksheet function. See how to call a wrapper function from a query, and …

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question