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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:00:11+00:00 2026-05-28T07:00:11+00:00

Recently I have been watching Plural Sight ASP.NET videos on data binding, and I

  • 0

Recently I have been watching Plural Sight ASP.NET videos on data binding, and I came across declarative data source controls such as <asp:SqlDataSource />.

I am having trouble understanding why I am unable to insert a default movie title and release date into my movies table in a sql server 2008 database. I haven’t had any trouble up until this point, and have been able to access the table via SelectCommand through a gridView, but when I click on the insert movie button, the new manually made movie parameters aren’t added to the table.

Here is my code for a better look:

InsertCommand="INSERT INTO movies (title, release_date) VALUES (@title, @release_date)"
SelectCommand="SELECT TOP 30 movie_id, title, release_date FROM movies ORDER BY movie_id DESC"
runat="server" ID="_moviesDataSource" DataSourceMode="DataReader">
<InsertParameters>
    <asp:Parameter Name="title" />
    <asp:Parameter Name="release_date"/>
</InsertParameters>
</asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" Text="Insert new movie" 
    onclick="Button1_Click" /><br /><br />
<asp:GridView ID="_moviesGridInsert" runat="server" DataSourceID="_moviesDataSource">
</asp:GridView>

As you may notice above, I did not have the Type=”…” in the Parameter asp tag, but before this, i had the types equal to string for title and dateTime for release_date. Could the problem possibly be that the values I have set in my database be different then the ones I declared above?

C# back-end of it:

protected void Button1_Click(object sender, EventArgs e)
{
    Page.MaintainScrollPositionOnPostBack = true;

    // TODO - Insert movie (manually inserted with just user input of button click)
    _moviesDataSource.InsertParameters["title"].DefaultValue = "My movie";
    _moviesDataSource.InsertParameters["release_date"].DefaultValue = "01/01/2008";
    _moviesDataSource.Insert();
}

I’m not allowed to post images yet, so adding the grid is not possible, even though it would help if you could view the table itself… But anyways, the table, once the button is clicked, stays the same, and when I look in the database, the new values aren’t added.

  • 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-05-28T07:00:12+00:00Added an answer on May 28, 2026 at 7:00 am

    There was absolutely nothing wrong with anything inside of the SqlDataSource tag or in the Button1_Click() Method.

    Problems:

    1. There was a validation form that wouldn’t allow the Page to validate until the form was filled out because I had Page.Validate(). I fixed this by adding all of the form validations to a Group ID and setting: Page.Validate(“form1”).
    2. After the above was fixed, I then had to go to my table settings (which can be done easier on Visual Studio then in SQL Management) and set the movie_id to auto-increment. The reason for this is that this value wasn’t in the parameters, and so if it doesn’t auto-increment, it will try to set this value of the column to NULL (and in most cases, NULL isn’t allowed or not wanted in my case).

    @Steve Wellens, thanks for the effort! Hope someone can learn from this little tip!

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

Sidebar

Related Questions

Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
recently I have been encountering problems with exposing events from .NET to COM. I
Recently I have been working on sockets in C++ and I have come across
I recently have just been able to populate my core data DB. I have
I am a .NET guy but recently have been placed on a Java project.
I have been a .net developer for many years and have recently become interested
I have been practicing TDD in C# for several years now and recently have
Recently I have been learning about WMI and WQL. I found out the list
Recently I have been asked an interview question What are the events order in
I have been an iphone developer for a while, and I have recently been

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.