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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:27:06+00:00 2026-05-31T16:27:06+00:00

I am trying to build a DataTable to populate a DataGrid in VB.NET. The

  • 0

I am trying to build a DataTable to populate a DataGrid in VB.NET.

The columns will be the username and then question from an exam.

Each row will be the answers by user for each question.

So it would look something like this:

Username  |   What is your favorite color? |  What is your favorite book?
-------------------------------------------------------------------------
Joe           Blue                            The Hobbit 

Fred          Red                             The Road

Jill          Orange                          Old Mans War

I am getting all my questions and running through a loop to add to the columns like this:

        Dim table As New DataTable
        table.Columns.Add("Username", GetType(String))

        For Each q In query
            table.Columns.Add(q.question.Stem, GetType(String))
        Next

        myDg.DataSource = table
        myDg.DataBind()

That works great and gives me a table that has the needed columns, but I am stuck as to how and get each users answer and put it under the appropriate column.

I tried adding rows in the same loop, but that just adds all of the answers under the first column.

Any help or ideas would be welcomed!

Thanks!

  • 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-31T16:27:08+00:00Added an answer on May 31, 2026 at 4:27 pm

    You don’t specify where this data is coming from but an easier solution would be to have the data in the format:

    UserName    Question                        Answer
    
    Joe         What is your favorite color?    Blue
    

    It’s simple to retrieve the answer to each question then and I suspect (I hope) this mirrors your database a bit more accurately.

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

Sidebar

Related Questions

I'm trying to populate a DataTable, to build a LocalReport, using the following: MySqlCommand
I am trying build a DataTable one row at a time using the following
I ran into a problem trying to remove a row from a datatable in
I am trying to boild my treeview at runtime from a DataTable that is
I'm trying build a method which returns the shortest path from one node to
I have a std::vector< tr1::shared_ptr<mapObject> > that I'm trying build from data contained in
I'm trying build a regex that will replace any characters not of the format:
Trying to build a plugin effect that will some what look better than this
I'm trying to build a list that will be used as the in clause
I am using ASP.NET MVC 3. I am trying to populate my YUI data

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.