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 9235721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:07:09+00:00 2026-06-18T07:07:09+00:00

I am attempting to learn ASP.NET and want to use an ObjectDataSource to select

  • 0

I am attempting to learn ASP.NET and want to use an ObjectDataSource to select and insert into a database. I am using a business class that has an insert method that has an object as its parameter. Several sources I’ve looked at say that this is a correct way of doing this but I have been unable to find out how to insert into the database using c# in the code behind file. I have a form that pulls from two other tables using ObjectDataSources that work correctly but I need to use a button to insert the record that I am creating into the table. I do not seem to be able to add the object I have created into the InsertParameters of the ObjectDataSource so I want to know if there is a method of doing this.

The insert method’s signature looks like this:

public static void InsertIncident(Incident incident)

The ASP code that Visual Studio generated looks like this:

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
  DataObjectTypeName="Incident" InsertMethod="InsertIncident"
  OldValuesParameterFormatString="original_{0}"  SelectMethod="GetIncidents" 
  TypeName="IncidentDB"></asp:ObjectDataSource>
  • 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-18T07:07:10+00:00Added an answer on June 18, 2026 at 7:07 am

    I feel a little bit silly now, but I found out what I was doing wrong. I didn’t need to use the ObjectDataSource for inserting the object at all. I should have just called the insert method directly.

    if (IsValid)
    {
      Incident i = new Incident();
      i.CustomerID = Convert.ToInt32(ddlCustomer.SelectedValue);
      i.ProductCode = ddlProduct.SelectedValue;
      i.DateOpened = DateTime.Today;
      i.Title = txtTitle.Text;
      i.Description = txtDescription.Text;
    
      try
      {
        IncidentDB.InsertIncident(i);
      }
      catch (Exception ex)
      {
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to learn how to use Cucumber and creating steps using the following
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be
I'm starting to learn ASP.NET (Razor, .NET Framework 4.5), and now am attempting to
I have been attempting to learn Grails, however I am running into the following
I am attempting to learn J and the book I am using says this
I am attempting to learn how to program. I really do want to learn
Hey all I am attempting to learn MVC 2 and ASP etc through the
I'm attempting to learn C and already I've run into an issue. I assume
I am a student attempting to learn VB.NET on my own. Today I wanted
I am attempting to learn to use RapidMiner, and my boss wants me to

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.