Last post Jan 25, 2008 09:46 PM by nikki_doer_of_things
Jan 25, 2008 05:30 PM|abdulbq|LINK
I need to create the data grid dynamically from the sql server tables, i.e. my table structure may change on a day to day basis, what is the best way to accomplish this on a aspx page using datagrid/grid view.
I am using asp.net 2.0 and my table structure may change on a daily or weekly basis.... it may be not that frequent but I want to have the capability to dynamically generate database columns in the grid , either there are 10 columns or 5 columns .
Jan 25, 2008 06:55 PM|nikki_doer_of_things|LINK
I suppose you could just set autogenerate columns on and select *, but why would you need to change table structure all the time, or even at all after you're done with developing your application? I can see the occasional change as the application evolves,
but constant changes may be indicative of poor design.
Jan 25, 2008 07:37 PM|abdulbq|LINK
well, the thing is this....
For my web app there will be two user groups...........
1. admin users
2. end users
admin users can define fields from the front end to extend the tables if needed , this will not be frequent but may happen few times in a year , if they see a future need to extend the table.. from the web app they can add some additional columns and when
they do this those columns should automatically become visible in the grid control...
end users will only use the data... no change rights for them.
the other challenge that I have is that I will also need to modify the userr interface where they enter the data to automatically generate the controls if they add a column in the table.
Jan 25, 2008 09:46 PM|nikki_doer_of_things|LINK
If you explain more about exactly what you're trying to accomplish, we can probably come up with a much nicer architecture for this. You really don't want your web application to have create or alter permissions in your database. That's a huge security risk,
and just isn't needed.
So, for example, when you say admins can define fields to extend the tables, you're thinking about it terms of your one table, maybe a customer. So if you want them to be able to add attributes to the customer, you don't add a column in the customer table.
You add a second table, CustomerAttributes (columns in this table would include the customer id, attribute name, attribute value, perhaps a data type so it can be rendered formatted, and so on), and link it to the customer table via the unique customer id.
Each custom attribute ("column") is then stored in that table. They can then create as many as they want to.
You are thinking horizontally. You need to think vertically.