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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:21:15+00:00 2026-05-25T23:21:15+00:00

The reason why I am having a hard time populating this table is because

  • 0

The reason why I am having a hard time populating this table is because the table get’s created dynamically:

MySql.Data.MySqlClient.MySqlDataReader selection = mySql.QuerySelect(textBox1.Text);  //textBox1.Text containts the text of the query to be executed

DataTable table = new DataTable();  // create table to hold results

// depending on the query construct the needed columns
for (int i = 0; i < selection.FieldCount; i++)
{
    table.Columns.Add("Column " + i);
}

// while there are rows insert them
while (selection.Read())
{
    object[] o = new object[selection.FieldCount];
    for(int j=0; j<selection.FieldCount; j++)
    {
        o[j] = selection[j].ToString();
    }
    table.Rows.Add(o);
}

ok so far after this point my table is constructed.

now my problem is how can I display that table so that user can see the results.

here are the things I have tried:

with a datagrid:

<DataGrid AutoGenerateColumns="False" Margin="73,264,17,12" Name="dataGrid1" ItemsSource="{Binding}" />

code behind:

dataGrid1.DataContext = table.DefaultView;

that does not display the results. the rows get populated and rows two but with no content…

with ListView

<ListView Height="72" Margin="78,253,17,0" Name="listView1" VerticalAlignment="Top" ItemsSource="{Binding}" />

code behind:

            listView1.DataContext = table.DataSet;
            listView1.DataContext = table.DefaultView;

enter image description here

note the correct number of rows are displayed but with the wrong content.

with a ListBox

similar technique….

  • 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-25T23:21:15+00:00Added an answer on May 25, 2026 at 11:21 pm

    You want columns in your grid, so you probably don’t want AutoGenerateColumns="False".

    To use a <ListView>, you’ll need to make columns yourself in a <GridView>.

    To use a <ListBox>, set DisplayTemplate to a <DataTemplate> containing UI for the listboxes.

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

Sidebar

Related Questions

I'm having a hard time finding the solution for this for some reason --
For some reason, I'm having a hard time trying to cover the block of
I've been having a hard time coming up a solution with this one. I'm
I'm having a bit of a hard time. Essentially I need a data structure
Hey everyone. This seems easy enough, but for some reason I'm having a hard
I've experienced this first hand but I'm having a hard time locating any resources
For some reason i'm really having a hard time wrapping my head around HABTM
Having a hard time parsing XML created from a web-form using POST. Here's the
I am having a hard time figuring out good reasons for the dependency property.
For some reason I'm having a problem retrieving data from my database. It leaves

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.