Click here to Skip to main content
15,921,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Actually i want to create a table dynamically by taking the values from the grid view.

ie, The header values of the Grid view should taken as the columns of the table.
That is in database the table has to store exactly how the data is represented in Grid view.

What I have tried:

I asked this doubt to many professors in my University and nobody able to help me out on this. So this is my last attempt as i dont have any idea to how to code it.
Posted
Comments
[no name] 19-Jun-18 16:51pm    
Got a "grid" running yet?

Bet not.
Member 13858616 19-Jun-18 17:00pm    
Yes its a data grid which displays on my webpage after some code manipulations.
Member 13858616 19-Jun-18 17:01pm    
Its fully generated grid. All the data are available in Grid.
[no name] 19-Jun-18 17:43pm    
Then that "grid" is an HTML table; which you, Excel, etc can "scrape" and put into a table.

And since it's also "your web page", you also have access to the "source data".

So, your "professors" don't sound like "real" professors...

Eric Lynch 19-Jun-18 18:15pm    
If you're wondering why you have received so little response, its because you haven't even provided any detail for people who want to help. There is so little detail that people don't even know what questions to ask to get the missing detail.

The terms "grid" and "webpage" are ridiculously generic. There are hugely different approaches to presentation. Most modern web applications fetch data via a RESTful service and deal with the presentation work (creating the HTML for the grid) on the client-side. Older web applications (and some modern ones) create the HTML on the server-side. Any clue about the basic architecture of your application might help people to ask intelligent questions.

With either architecture, there is ultimately some data source for the grid. This could come in the form of a DataTable class or a collection of strongly-typed objects. Any clue about the data source, and more importantly the nature of the data, might help people to ask intelligent questions.

Assuming we knew anything about the application or the data, the next question would be exactly what you are trying to do. It seems, if I read correctly, you want to generate a database schema, create a database table from this schema, and populate it with the data from your application.

If correct, this is a very unusual requirement. We'd need to understand more about why? For example, are users able to add and remove columns from your grid? Are they able to change column names? Are they able to change the data types for those columns? If the answer to all of these questions is "no", then there is no need to dynamically generate anything. There are much better approaches that people might suggest.

If you are truly giving the user the ability to directly influence the creation of database tables, via your webpage, then this is a design that carries a fair amount of risk, both to application stability and potentially security as well.

If this is correct, I would recommend against this approach. There are almost always better approaches, if the requirements are truly understood.

Assuming all of this is true, and you're willing to assume the risk, we'd have to better clarify "store exactly". There are data types in C# that simply don't exist in some databases. Which, I guess brings up yet another question, what database are you using (SQL Server, MySQL, Oracle, etc.)? There are differences in syntax and data types between databases.

The final question is what you plan to do with the data once you store it? Will the webpage try to query it later? If the user can change the schema, via the webpage, and you query the table later, how do you plan become aware of a change in the schema? Do you need to also know how to query table metadata from a database?

In short, I think you need to more carefully consider your requirements and articulate them, before anyone even knows what questions to ask you, so that they can help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900