Solved

ASP.Net GridView

Posted on 2012-12-31
2
330 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

685 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