Solved

ASP.Net GridView

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to pass connection string through config 2 26
Runtime Error 2 27
Data is not showing from images 15 37
Error on Add method 1 37
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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

932 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

8 Experts available now in Live!

Get 1:1 Help Now