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

x
?
Solved

save changes C# - LINQ - ASP.NET

Posted on 2013-01-11
2
Medium Priority
?
332 Views
Last Modified: 2013-01-14
Consider this code for filling in the data for a record:

  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;
            }         

Open in new window




How to I then save any changes using the same construct at a later time?

In other words:

Models.AgentFormEdit_AgentForm_GetResult

is how I get my data

so I need the analog:

Models.AgentFormEdit_AgentForm_Update?


I can write a stored procedure to do the update...not sure of the C# ( LINQ? ) syntax...
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 18

Accepted Solution

by:
Gary Davis earned 2000 total points
ID: 38770080
You can execute a stored proc out of the datacontext using ExecuteCommand() or if the SP is part of the AgentFormsDataContext, it will be available to call directly as a method of the context.

Alternatively, you could issue your dc.AgentFormEdit_AgentForm_Get() call to initialize the context with the data, update the fields in the loop similar to above (the datacontext will track the changed properties) and finally, call SubmitChanges().
0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 38776361
Thank you!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

609 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