473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DetailsView or FormView, how to set SelectedIndex?

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
Nov 19 '05 #1
1 10049
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

|
|

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
4
by: P. Yanzick | last post by:
Hello, I've been playing with master/detail views as well as editing in the gridview, and I ran across a strange problem that I am not exactly sure where to go to try to solve. I have 2...
1
by: cisco | last post by:
I've been trying to figure out how the client of a DetailsView or FormView should handle the ItemUpdating event when setting the datasource programatically. I want to do something simple like...
1
by: JayD | last post by:
Here is the problem: Using asp.net 2.0 to create a web app with standard master table gridview and child detailsview with insert capability. SQL Server 2000 database on the backend. Using Visual...
1
by: R.A.M. | last post by:
Hi, I am learning .NET 2.0 and I would like to know what is the difference between DetailsView and FormView? When, IN PRACTICE, use each of these? Thank you! /RAM/
2
by: nolan | last post by:
I have an asp.net 2.0 page with a gridview and detailsview on the same page set up in a master-details scenario. The gridview and detailsview have separate SQL data sources. The user enters...
0
by: ThePurpleCat | last post by:
Hi, I'm a newbie to ASP.NET programming but not to Visual Studio. I'm having trouble getting my Master-Details page to work. I have a page enabled GridView which is linked to a FormView control...
2
by: Paulo | last post by:
What is DetailsView, FormView, DataList, Repeater components? Any differences? VS 2005 asp.net C#
0
by: gsauns | last post by:
I have a DetailsView which is inside of a FormView. I lifted this DetailsView straight off another one of my pages, where it was working beautifully. Now I get this endlessly frustrating error...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.