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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:55:07+00:00 2026-05-25T12:55:07+00:00

I have a list view listed with category names coming from database i am

  • 0

I have a list view listed with category names coming from database i am trying to populate the data grid view by using selection item in list view by the following method…….

    if (lstviewCatgeories.SelectedItems.Count > 0 && lstviewCatgeories.SelectedItems[0].Group.Name == "catgories")
     {

              string text = lstviewCatgeories.SelectedItems[0].Text.ToString();
                var categorywithids = (from categorytypes in dbentity.categories
                                       where categorytypes.category_Name.Equals(text)
                                       select categorytypes.category_Id).SingleOrDefault();


                var productsbycounts = dbentity.products.GroupBy(x => x.product_Id).Where(a => a.FirstOrDefault().category_Id.Equals(categorywithids))
                                      .Select(a => new
                                      {
                                          productid = a.Key,
                                          productname = a.FirstOrDefault().product_Name,
                                          productimage = a.FirstOrDefault().product_Image,
                                          productdescription = a.FirstOrDefault().product_Description,
                                          stockavailable = a.LongCount(),
                                          productprice = a.FirstOrDefault().product_Price

                                      });
                productsall.DataSource = productsbycounts;
                dgvAllproducts.DataSource = productsall;
                dgvAllproducts.Columns[0].Visible = false;
                dgvAllproducts.Columns[3].Visible = false;
                DataGridViewButtonColumn column = new DataGridViewButtonColumn();
                dgvAllproducts.Columns.Add(column);
                column.FlatStyle = FlatStyle.System;
                column.DefaultCellStyle.ForeColor = Color.ForestGreen;
                column.DefaultCellStyle.Padding = new Padding(10, 48, 10, 48);
                column.Text = "Buy";
                column.HeaderText = "Buy";
                column.UseColumnTextForButtonValue = true;
                column.Name = "btnbuy";
         }

why i am not able to see the products even if they are products related to category …….

i have seen count 6 at this line productsall.DataSource = productsbycounts;

would any one pls e help on this…….

  • 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-25T12:55:07+00:00Added an answer on May 25, 2026 at 12:55 pm

    I’m not sure but based on the code that you submitted, your assigning the DataSource property of dgvAllproducts (that I think is a DataGridView) to what I think is another control (a DataGridView), i.e. : productsall.

    dgvAllproducts.DataSource should be set with a real datasource, not with a DataGridView. Sorry if I’m missing something.

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

Sidebar

Related Questions

I have to list several elements that are coming from a database source A
I have list of books listed on the user's profile from the database,i want
I have list view with names and numbers and checkbox populated from contacts with
I have a list view filled with data. I set up a context menu
I currently have a list view which has several rows of data and I
I have used a list view that uses a grid view in WPF. I
I have created a list view that displays the names and dates of items
We have created a new List View Style that shows thumbnails from a picture
I have a list view control which at the moment only allows one item
I have a list view that is periodically updated (every 60 seconds). It was

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.