?
Solved

ASP.Net GridView

Posted on 2012-12-31
2
Medium Priority
?
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1500 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

Independent Software Vendors: 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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

719 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