Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 11th, 2007, 02:38 AM
Authorized User
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yukijocelyn
Default detailsview.pageindex = gridview.selectedindex

Hi

I'm stuck at this problem here. When I put thi statement
"detailsview.pageindex = gridview.selectedindex"
I can only see the correct one provided that the gridview have not been sorted or paged before.
How can I overcome this problem?

Thank you
 
Old September 11th, 2007, 11:28 AM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

I think the details view may simply be giving you the default initial value. It sounds like it's not pulling the correct values from the database at all. It just looks like it, because the default SELECT looks the same as your unsorted unpaged gridview. Can you post your database access code?

-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
 
Old September 11th, 2007, 08:36 PM
Authorized User
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yukijocelyn
Default

Hi chroniclemaster1

Thank you for replying. Yes, it gives me the initial loaded value only. However, I would like it not to give me that.
Below are my codes:

ASP GridView
<asp:GridView ID="GridView1" runat="server" Height="308px" Style="z-index: 106; left: 15px; position: absolute; top: 146px" Width="512px" Font-Names="Arial Narrow" CellPadding="4" ForeColor="#333333" GridLines="None" PageSize="20" OnPageIndexChanging="GridView1_PageIndexChanging" AllowPaging="True" AutoGenerateSelectButton="True">
  <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White"/>
  <RowStyle BackColor="#EFF3FB" />
  <EditRowStyle BackColor="#2461BF" />
  <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
  <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
  <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  <AlternatingRowStyle BackColor="White" />
</asp:GridView>

Bind database record to GridView
Private Sub BindData()
  Dim dbconn As OleDbConnection
  Dim sql As String
  Dim dbcomm As OleDbCommand
  Dim dataAdap As OleDbDataAdapter
  Dim ds As DataSet

  dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & Server.MapPath("DB.mdb"))
  dbconn.Open()
  sql = "SELECT ID, acct, eNo, Name FROM table"
  dbcomm = New OleDbCommand(sql, dbconn)
  dataAdap = New OleDbDataAdapter(dbcomm)

  ds = New DataSet
  dataAdap.Fill(ds)

  GridView1.DataSource = ds
  GridView1.DataBind()

End Sub

My DetailsView currently is running on AccessDataSource control, I linked it to a drop down list where user can choose by the ID. However, I want to change it to be able to use the selection button in the gridview.

The initial code for the DetailsView to actually show the result after selection button is clicked, but the problem lies here.
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs)
  DetailsView1.PageIndex = GridView1.SelectedIndex
End Sub

Above are my codes, please advice.
Thank you!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Gridview to Edit NOT DetailsView ? kalel_4444 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 December 4th, 2008 11:36 PM
VB GridView & DetailsView Rich57 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 February 1st, 2008 12:03 PM
GridView.SelectedIndex Prop SteveP55419 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 October 8th, 2006 09:08 PM
Button on GridView that goes to DetailsView AndrewD ASP.NET 2.0 Basics 0 November 30th, 2005 11:09 AM
Can't get DetailsView to work with GridView oneworld95 ASP.NET 2.0 Basics 3 July 16th, 2005 07:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.