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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:18:12+00:00 2026-05-22T12:18:12+00:00

hi i have a very simple webform i have a button and a gridview

  • 0

hi
i have a very simple webform
i have a button and a gridview on this form and a dataset that contains linked tables bill, docket, docket_bill etc.

On Button click i use the following code

  protected void button_click(object sender, EventArgs e)
{
billTableAdapter Billta = new billTableAdapter();
gridview1.datasource = Billta.getTop20Bills();
gridview1.databind()'
}

Now when i click on the button, i get the following error

“Failed to enable constraints. One or
more rows contain values violating
non-null, unique, or foreign key
constraints”

However, when i change the code to

 protected void button_click(object sender, EventArgs e)
    {
    billTableAdapter Billta = new billTableAdapter();
    gridview1.datasource = Billta.getdata();
    gridview1.databind()'
    }

It works fine. billTa.getData() gets all the rows from the dataset and shows up in the gridview. but when i add a query and select only few columns, then it gives me the aforementioned error.

Any idea what is wrong here?

SQL Scripts for getdata() = select * from bill

SQL script for getTop20Bills = select top 20 bill_id, bill_amount from bill
  • 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-22T12:18:13+00:00Added an answer on May 22, 2026 at 12:18 pm

    I guess you have more than two columns in your billTableAdapter. In getTop20Bills() you select only two columns you need. You have to add missing columns to your second script. Or you can create new Table Adapter, that contains only this two columns and bind grid view to new adapter

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

Sidebar

Related Questions

I have very simple script for submitting the form. This is html template: <table>
i have very simple problem. I need to create model, that represent element of
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have a very simple bit of script that changes the status of an
I have a very simple Java RMI Server that looks like the following: import
I have a very simple ASP.Net page that acts as a front end for
I have a very simple web form which consists of labels and input fields,
I have a very simple webforms app that will allow field techs to order
I have very simple situation and really don't have a clue why this isn't
i have very simple basic form in HTML and i want to validate the

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.