Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8979611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:53:14+00:00 2026-06-15T19:53:14+00:00

Using Visual Studio 2012 and SQL Server 2012 Here is the situation: A website

  • 0

Using Visual Studio 2012 and SQL Server 2012

Here is the situation:

A website I am building is not updating data that is loaded into fields from a SQLDataSource. The data loads just fine into their appropriate text boxes, but when I go to edit the data and activate a button click, it looks like the revisions are cleared and the page refreshes to the original loaded data. As far as I can tell, my code looks correct, but that is obviously not the case.

Addition info:

I have the page set up in a containerplaceholder with a master page.

Here is my mark up:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

<!-- Job Title -->

<div class="lbljobtitle">
    <asp:Label ID="lblJobTitle" runat="server" Text="Job Title"></asp:Label>
</div>

<div class="txtjobtitle">
    <asp:TextBox ID="txtJobTitle" runat="server" Height="22px" Width="250px"></asp:TextBox>
</div>

<!-- Employee Type -->

<div class="lblemployeetype">
    <asp:Label ID="lblEmployeeType" runat="server" Text="Employee Type"></asp:Label>
</div>

<div class="txtemployeetype">
    <asp:TextBox ID="txtEmployeeType" runat="server" Height="22px" Width="250px"></asp:TextBox>
</div>

<!-- Location -->

<div class="lbllocation">
    <asp:Label ID="lblLocation" runat="server" Text="Location"></asp:Label>
</div>

<div class="txtlocation">
    <asp:TextBox ID="txtLocation" runat="server" Height="22px" Width="250px"></asp:TextBox>
</div>

<!-- Job Description -->

<div class="lbljobdescription">
    <asp:Label ID="lblJobDescription" runat="server" Text="Job Description"></asp:Label>
</div>

<div class="txtjobdescription">
    <asp:TextBox ID="txtJobDescription" runat="server" Height="160px" Width="250px" TextMode="MultiLine"></asp:TextBox>
</div>

<!-- Requirements -->

<div class="lblrequirements">
    <asp:Label ID="lblRequirements" runat="server" Text="Requirements"></asp:Label>
</div>

<div class="txtrequirements">
    <asp:TextBox ID="txtRequirements" runat="server" Height="160px" Width="250px" TextMode="MultiLine"></asp:TextBox>
</div>

<!-- Experience -->

<div class="lblexperience">
    <asp:Label ID="lblExperience" runat="server" Text="Experience"></asp:Label>
</div>

<div class="txtexperience">
    <asp:TextBox ID="txtExperience" runat="server" Height="22px" Width="250px"></asp:TextBox>
</div>

<!-- Date Posted -->

<div class="lbldateposted">
    <asp:Label ID="lblDatePosted" runat="server" Text="Date Posted"></asp:Label>
</div>

<div class="txtdateposted">
    <asp:TextBox ID="txtDatePosted" runat="server" Height="22px" Width="250px"></asp:TextBox>
</div>

<!-- Start Date -->

<div class="lblstartdate">
    <asp:Label ID="lblStartDate" runat="server" Text="Start Date"></asp:Label>
</div>

<div class="txtstartdate">
    <asp:TextBox ID="txtStartDate" runat="server" Height="22px" Width="250px"></asp:TextBox>
</div>


<asp:Button ID="btnUpdate" runat="server" Text="Update Job" OnClick="btnUpdate_Click" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:bgrecruit_d01ConnectionString %>"
    SelectCommand="SELECT job_title, employee_type, location, job_description, requirements, experience, date_posted, start_date, requisition_id FROM jobopening_tbl WHERE (requisition_id = @requisition_id)"
    UpdateCommand="UPDATE [jobopening_tbl] SET [job_title] = @job_title, [employee_type] = @employee_type, [location] = @location, [job_description] = @job_description, [requirements] = @requirements, [experience] = @experience, [date_posted] = @date_posted, [start_date] = @start_date WHERE [requisition_id] = @requisition_id">

    <SelectParameters>
        <asp:QueryStringParameter Name="requisition_id" Type="String" QueryStringField="req_id" />
    </SelectParameters>

    <UpdateParameters>

        <asp:Parameter Name="job_title" Type="String" />
        <asp:Parameter Name="employee_type" Type="String" />
        <asp:Parameter Name="location" Type="String" />
        <asp:Parameter Name="job_description" Type="String" />
        <asp:Parameter Name="requirements" Type="String" />
        <asp:Parameter Name="experience" Type="String" />
        <asp:Parameter Name="date_posted" Type="String" />
        <asp:Parameter Name="start_date" Type="String" />
        <asp:Parameter Name="requisition_id" />
    </UpdateParameters>


</asp:SqlDataSource>

And my C#:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public partial class UpdateDetail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
    DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    DataRowView row = dv[0];

    txtJobTitle.Text = row["job_title"].ToString();
    txtEmployeeType.Text = row["employee_type"].ToString();
    txtLocation.Text = row["location"].ToString();
    txtJobDescription.Text = row["job_description"].ToString();
    txtRequirements.Text = row["requirements"].ToString();
    txtExperience.Text = row["experience"].ToString();
    txtDatePosted.Text = row["date_posted"].ToString();
    txtStartDate.Text = row["start_date"].ToString();             

}
protected void btnUpdate_Click(object sender, EventArgs e)
{
    DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    DataRowView row = dv[0];

    SqlDataSource1.UpdateParameters["job_title"].DefaultValue = txtJobTitle.Text.ToString();
    SqlDataSource1.UpdateParameters["employee_type"].DefaultValue = txtEmployeeType.Text.ToString();
    SqlDataSource1.UpdateParameters["location"].DefaultValue = txtLocation.Text.ToString();
    SqlDataSource1.UpdateParameters["job_description"].DefaultValue = txtJobDescription.Text.ToString();
    SqlDataSource1.UpdateParameters["requirements"].DefaultValue = txtRequirements.Text.ToString();
    SqlDataSource1.UpdateParameters["experience"].DefaultValue = txtExperience.Text;
    SqlDataSource1.UpdateParameters["date_posted"].DefaultValue = txtDatePosted.Text;
    SqlDataSource1.UpdateParameters["start_date"].DefaultValue = txtStartDate.Text;
    //requisition_id = @requisition_id
    SqlDataSource1.UpdateParameters["requisition_id"].DefaultValue = row["requisition_id"].ToString();

    SqlDataSource1.Update();

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:53:15+00:00Added an answer on June 15, 2026 at 7:53 pm

    Add the following if block so the code in your page_load looks like this:

    if(!Page.IsPostBack)
    {
      DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
      DataRowView row = dv[0];
    
      txtJobTitle.Text = row["job_title"].ToString();
      txtEmployeeType.Text = row["employee_type"].ToString();
      txtLocation.Text = row["location"].ToString();
      txtJobDescription.Text = row["job_description"].ToString();
      txtRequirements.Text = row["requirements"].ToString();
      txtExperience.Text = row["experience"].ToString();
      txtDatePosted.Text = row["date_posted"].ToString();
      txtStartDate.Text = row["start_date"].ToString();  
    }
    

    The problem is that page_load runs on every post back (including button clicks). I suspect you only want to run that code when the page originally loads which is what adding the if does.

    Remember this, because you will run into this issue approximately 28972 more times if you keep programming with .NET.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am trying to post json data to the server. am using visual studio 2012
I have a package that is developed in SSIS 2012 using Visual Studio 2010.
Using C#, .NET 4, SQL, visual studio 2010 and sql server manager 2008. Hi
How do I generate test data using Visual Studio 2012? I found these 2
I recently installed Visual Studio and SQL Server 2012. I'm wondering if I'm missing
I'm trying to create a Microsoft SQL Report in Visual Studio 2012. My data
I'm using Visual Studio 2012 to develop simple Win32 C programs. I know that
I recently installed Visual Studio 2010 and SQL Server 2012 on a Windows Server
Started using Visual Studio 2012 RC since yesterday, We have one WCF solution. Whenever
I'm using Visual Studio 2012 for Windows Phone 7 and this is my first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.