Dynamic Data-binding in C#

  • Thread starter Thread starter Fir5tSight
  • Start date Start date
F

Fir5tSight

Hi,

I have a grid that displays a few columns of data obtained from a
stored procedure. Now under certain condition, I'll need to add an
additional column to the same grid whose data are obtained from a
second stored procedure.

After I put my code in, the second stored procedure seems to be called
when the condition is met. However, the additional column is still
missing from the grid.

I believe that I'll need to add the column to the grid specifically in
the code. However, I'll need to get the column added dynamically only
when the condition is met. Could anyone advise me on how to do this?

Thanks!

-Emily
 
Hi,

I have a grid that displays a few columns of data obtained from a
stored procedure. Now under certain condition, I'll need to add an
additional column to the same grid whose data are obtained from a
second stored procedure.

After I put my code in, the second stored procedure seems to be called
when the condition is met. However, the additional column is still
missing from the grid.

I believe that I'll need to add the column to the grid specifically in
the code. However, I'll need to get the column added dynamically only
when the condition is met. Could anyone advise me on how to do this?

Thanks!

-Emily

Not really enough information in your post...but adding (or
showing/hiding) a new column can be done via the grid's Columns
collection. Also check out the AutoGenerateColumns property of the
DataGridView (it's a pain that this is not available in the properties
window).
 
Hi Phil,

Thanks for responding! You're right that this is in the column
collection. I've created classes that would return all of the columns
(including the additional column) for a data set.

Therefore, I have two data sets in the program. One is the old one. The
other is the new one that includes the additional column.

I'll need to figure out where to set the new data set as data source to
the grid so that the grid can display all of the columns. Any advice on
that?

-Emily
 
Back
Top