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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:05:25+00:00 2026-06-07T21:05:25+00:00

When I open my form, I’m adding a bunch of rows to a DataSet

  • 0

When I open my form, I’m adding a bunch of rows to a DataSet that is bound to a DataGridView. Later on, when I’m enumerating the rows in my DataGridView, I’d like to have access to some of the data that was used to populate the DataSet but is not stored in the DataSet proper.

Something like this:

public void OnStartup()
{
  foreach (var data in GetData())
  {
    var row = MyDataSet.MyTable.AddRow(data.Value);

    // here's the part where I'm not sure what to do.. ideally:
    row.GetDataGridViewRow().Tag = data.Metadata;
  }
}

public void LaterOn()
{
  foreach (var row in MyDataGridView.GetSelected())
  {
     var metadata = (Metadata)row.Tag;  // or something
     ...
  }
}

What is the best way to attach some metadata to a DataSet or DataGridView row?

  • 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-06-07T21:05:27+00:00Added an answer on June 7, 2026 at 9:05 pm

    I would say that this is one of those situations where there is no single ‘right’ way of doing it, just a matter of choosing an approach on a case by case basis.

    There is nothing wrong with using the DataGridView Tag property like this. Indeed, that is it’s purpose, as stated on MSDN:

    The Tag property can store any object that you want to associate with
    a band. This property is typically used to store identifying
    information, such as a string name, a unique identifier (for example,
    a Guid), or the index of the band’s data in a database.


    One alternative that I would consider is to use a BindingList<T> with custom backing objects as the DataSource rather than a DataSet and store the meta data in the backing objects. You can then access each object using the DataGridViewRow‘s DataBoundItem property.

    I would marginally favour this way since it keeps the data and the UI a little more separated and means you can grab the meta data even when you only have the backing object, but I doubt that there is any concrete difference in terms of performance or memory usage.

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

Sidebar

Related Questions

I have a form that can open a sub form (with ShowDialog ). I
Hi i have managed to open .xls files form mail app by adding document
If I have a form open already that is not modal, can I turn
Well, I have a form that I open using: ShowDialog(this); I try to change
What I would like to do is display the following in a form: Open
I have a dialog form and when I open it I have the button
I am using fancybox to open submitted form like this: <form name=form id=myForm action={$smarty.server.PHP_SELF}?action=abc
In a container form I have menu and buttons to open ther forms. Here
I've got a form and a button on it. I would like to open
How can I get Visual Basic to open another form using code? I have

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.