开发者

Is it possible for a user to reference a previously created datatable by entering a string?

开发者 https://www.devze.com 2023-02-18 17:36 出处:网络
I want a quick way to be able to see all of the data that is currently in a DataTable. I want to be able to reference the name of the DataTable by entering string into a TextBox, have my program recog

I want a quick way to be able to see all of the data that is currently in a DataTable. I want to be able to reference the name of the DataTable by entering string into a TextBox, have my program recognise that it's a DataTable that has data in it, and display that data in a 开发者_JAVA技巧DataGridView. Maybe this isn't the best approach but it's better than creating a Select Case scenario for each datatable I've created. Any ideas?


I think you should probably find a more robust way to do this. However, if you really do wish to use this model, you can associate a string to a DataTable using Dictionary<string, DataTable>. Look up the entered string (making sure to handle cases in which the string is not found) among the dictionary keys, and you'll have your DataTable.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号