Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-01-14
2
Medium Priority
?
425 Views
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:

code:
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)
        {
            FillProductTypeDDL();
            FillAgentFormFields();
        }

//        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";
            ddlProducts.DataBind();
        }

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

        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();
            Response.Redirect(prevPage);
        }

    }
}

Open in new window







markup:
<%@ 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');       
     });

     

     		
    </script>


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

   <%-- <asp:UpdatePanel ID="UpdatePanelAgentFormAdd" runat="server" 
        ChildrenAsTriggers="False">
    <ContentTemplate>--%>
    <div id="corpus">
        <div id = "agentformfields">
            <div>
                <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>
            <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>
            <div>
                <div id="formname" class="afa_label">Form Name</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxFormName" runat="server"></asp:TextBox></div>
            </div>
            <div>
                <div id="colist" class="afa_label">Colist</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxColist" runat="server"></asp:TextBox></div>
            </div>
            <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>
            <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>
            <div>
                <div id="extlink" class="afa_label">External Link</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxExternalLink" runat="server"></asp:TextBox></div>
            </div>
            <div>
                <div id="taskcode" class="afa_label">Task Code</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxTaskCode" runat="server"></asp:TextBox></div>
            </div>
            <%--<div>
                <div id="amfirm" class="afa_label">AM firm</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxAMFirm" runat="server"></asp:TextBox></div>
            </div>
            <div>
                <div id="client" class="afa_label">Client</div>
                <div class="afa_control"><asp:TextBox ID="TextBoxClient" runat="server"></asp:TextBox></div>                
            </div>
            --%><div>
                <div id="product" class="afa_label">Product</div>
                <div class="afa_control"><asp:DropDownList ID="ddlProducts" runat="server"></asp:DropDownList></div>
            </div>
            <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>  
             <div>                
                <div id="Div2" class="afa_label"> </div>                
            </div>   
             <div>                
                <div id="Div3" class="afa_label"> </div>                
            </div>   
            <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>
            </div>        
        </div>    
    </div>
 <%--   </ContentTemplate>
    </asp:UpdatePanel>--%>
    <div id="footer"></div>
<div id="end_cap"></div>
</div>

Open in new window

0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

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

       protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               FillProductTypeDDL();
               FillAgentFormFields();
             }
        }

Open in new window

0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38775300
Concur!

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

Great minds think alike, right?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

610 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