Solved

ASP.Net GridView

Posted on 2012-12-31
2
326 Views
Last Modified: 2013-02-19
hello,

I have an iqueryable<objectextended> collection which is passed to a gridview.
I want to update the properties of objectextended before passing it onto the gridview.

I tried to convert IQueryable to List and update the items in the list and convert the list back to IQueryable, but it doe not work.

Thank You.
0
Comment
Question by:skolanti
2 Comments
 
LVL 18

Expert Comment

by:Gary Davis
ID: 38734623
Try to create a deep copy of the collection. That is, iterate through the items and create a new list and new items within the list. You can do this with a code loop or you can use Linq to project a new list of items using .Select().
0
 
LVL 8

Accepted Solution

by:
JustAndrei earned 500 total points
ID: 38735229
I tried to convert IQueryable to List and update the items in the list and convert the list back to IQueryable, but it doe not work.
Surely you can't convert the list back to IQueryable, but you don't have to.
The GridView processes its data source with help of reflection: it just looks for certain properties of each data source item, no matter which type the latter is.
So, in general, the workflow is as follows:

1. Compose

Compose the query, which will give you an IQueryable.

2. Execute

Turn your query into a list. This is where your query will be executed in fact.

3. Project the results to a viewable form

Prepare the display data for your GridView in the linq Select method/expression. You may use a specific class or just an anonymous type.Of course, you may find it wise to combine or exchange steps 2 and 3.

4. Pass the data to the view

Pass the list to GridView.DataSource as an object. It will discover the items' properties you defined in your display [anonymous] type.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now