Typed DataSet

T

Techno_Dex

I have a typed dataset which was created from views in our database using
the IDE automation. I would rather not modify them because if they ever
need to be regenerated I don't want to have to continually add in extra
fields that don't exist in the database. My problem/question is this, in a
DataGridView when you bind a Typed Dataset, is there a way to have an extra
unbound column of sorts which is not part of the Typed Dataset? Currently I
am creating the Grid Columns that I want displayed and binding them to the
appropriate fields in the dataset but I want to add a boolean column at the
beginning that the user can mark with a checkmark to show the record is
selected. For some reason this sounds like it should be very simple to me,
but my brain isn't clicking this morning. Any ideas?
 
D

Dave Sexton

Hi Techno_Dex,

Add a column as you have been doing but don't set the DataPropertyName field, which is used to bind the column to the data. You
could also set the DataPropertyName field to a Boolean DataColumn that is added to the Typed DataSet at runtime (i.e. without
changing the .xsd). This would allow you to manage the state of the checkbox inline with the data of each row without affecting the
design-time schema.

If you have to do this on multiple forms I suggest instead adding a DataTable to your DataSet named after the existing DataTable and
append the word "View", such as "ExistingData" and "ExistingDataView" (or choose a more descriptive name), which can be used to hold
only those DataColumns that you are interested in binding to DataGridViewColumns but that does not necessarily relate 1:1 to an
actual database table. In fact, you could create an updateable View in your database to generate your DataTable and table adapters,
which is where you could add your boolean column. This approach is nice because it's strong-typed, the data schema can be managed
by a View in the database when the schema is shared with multiple forms and, in some cases, you can simply set AutoGenerateColumns
to true which will save you some time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top