Reputation: 1081
On a webpage, I am displaying a grid, where the rows automatically bind to the properties of a datasource. In my case, this datasource is a LINQ data context.
The problem is that a customer should be able to add his own rows to the grid. To do so, he adds entries in the database. To make the grid able to bind to theese rows, they need to be represented as properties in the LINQ data context.
But how can I add these properties? As far as I know, the LINQ data context is static, but if there is a way to add properties, depending on the database, it would be great.
Upvotes: 1
Views: 335
Reputation: 172616
The ASP.NET LinqDataSource
has a Select
property (of type string
) that can contain the (text representation of a) LINQ query, so you can change that query at runtime, based on values from the customer. Of course you need to be sure you are not open to any injection attack (LINQ injection in this case).
Another possibility is returning all columns from the database and simply hide them, based on the user's configuration.
Upvotes: 1