Hi Shawn,
Welcome to ASPNET newsgroup.
Regarding on the question on ASP.NET 2.0's GridView/ DetailsView, here are
some of my understandings:
For GridView Control, it'll perform databinding on the first page load and
then, in the sequential page loading, by default it won't rebind data
through datasource again unless we explicitly call databind method. For
detailsView, it is also a Template databound control as GridView, it can't
perform simple databinding( bing only a single dataobject through
properties), we need to priovide a DataSource for it and let it perform
databinding to populate data. so when used in master/details scenario,
it'll need to retrieve a key value from the GridView Control, then requery
the data records through this key value and rebind with the new retrieved
records. That's why it need a separate datasource (other than the
GridView's datasource control), and need to query the db eachtime the
GridView(master view) 's selectedindes change (if we do establish relation
ship between them).
I'm not sure on your detailed scenario, do you mean in your GridView you've
retrieved all the column info so that you don't need to requery the
DataBase for further fields to displayed in DetailsView (and reuse the
existing record data in GridView row)? If so, I think it's possible since
we can retrieve each binded record's fields' value from the GridView's Rows
collection. Then, if you need to display them in a separate form/view, we
can even use a simple Usercontrol rathern than use the DetailsView.
If you have any other ideas or concerns, please feel free to post here.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Message-ID: <fc*************************@msnews.microsoft.co m>
| From: Shawn Wildermuth <sw*********@newsgroup.nospam>
| Subject: DetailsView or FormView, how to set SelectedIndex?
| MIME-Version: 1.0
| Content-Transfer-Encoding: 8bit
| Content-Type: text/plain; charset=iso-8859-1; format=flowed
| X-Newsreader: JetBrains Omea Reader 671.6
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Date: Wed, 28 Sep 2005 00:13:39 -0700
| NNTP-Posting-Host: dsl254-060-195.sea1.dsl.speakeasy.net 216.254.60.195
| Lines: 1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:127592
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I have a *single* SqlDataSource that loads up a single result set that I
| show in a GridView. In the GridView, i've added a "Select" button and
handling
| the SelectedItem event. I also have a DetailsView (though FormView has
this
| same issue) where I want to be able to set the current item to bind to
from
| the DataSource. All the examples I've seen use two data sources and on
every
| *select* they do another round-trip to the Database (which makes no sense
| to me). So this doesn't make much sense, why are all the properties
ReadOnly?
|
| DetailsView.DataItem
| DetailsView.DataItemIndex
| DetailsView.DataKey
|
| The only one that isn't read only is DetailsView.PageIndex, but if you
use
| that...I cannot sort the GridView because then the index I get from the
Grid
| is sorted and the wrong ndex to use in the PageIndex.
|
| Ideas?
|
| Thanks,
| Shawn Wildermuth
| Speaker, Author and C# MVP
|
|