> So you have two "bindings" - one to the lookup table (DataSource,
> DisplayMember and ValueMember), and one to the actual table (SelectedValue).
> The trick is that DataSource in this case is unrelated to data bindings -
> it's only indicating where the list comes from.
Thanks, that's it!
> When you mention values from the datagrid row appearing in the other
> controls for editing, this appears to be at odds with the notion that the
> form is only used for adding data. Are the datagrid rows serving as default
> values or something?
The user can insert, delete and update rows locally, in the memory, but once
finished, the final data is inserted into the database. So, there really are
only INSERT operations going on.
Is there a way to easily create a DataTable that has the same structure as a
physical table in the database? Since there is no SELECT on this form which
would get me the DataTable to use as a data source, I have to manually
create one which has the same schema as the one in the database. I know
about DataReader.GetSchemaTable(), but is there a way to automatically
"apply" that information to a DataTable? Am I missing something obvious
(again)?
Thanks for the help.
Andy Becker - 30 Jul 2004 22:05 GMT
> Is there a way to easily create a DataTable that has the same structure as a
> physical table in the database? Since there is no SELECT on this form which
[quoted text clipped - 3 lines]
> "apply" that information to a DataTable? Am I missing something obvious
> (again)?
I would use a typed dataset, if you don't mind creating it at compile time.
In Solution Explorer, right click the project and then Add New Item. Choose
Dataset, name this puppy whatever you like, and then you will get a design
surface. From Server Explorer (same tool window as Toolbox, by default),
create a data connection to the DB. Then if you drag the table onto the
design surface, it will create a typed dataset for you, PK definition and
all, matching the table.
If you are talking about creating the table at runtime, I'm not sure how it
would be done. Clearly it can though, since the IDE does it in the steps I
just described.
Best Regards,
Andy
Joe S. - 31 Jul 2004 12:57 GMT
> If you are talking about creating the table at runtime, I'm not sure how it
> would be done. Clearly it can though, since the IDE does it in the steps I
> just described.
Creating it at runtime is what I meant, but I managed to work around this
problem.
Thank you very much for your extensive replies.
Joe