472,952 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Master-Details with GridView and FormView and Paging

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 through an
objectdatasource. The paging on my GridView works fine except that when
I change the page the FormView
does not update. I tried setting the selectedindex to 0 in the
GridView's PageIndexChanged event and manually binding the formview but
the selectedvalue that the function sees is the old value from
the page being changed from and not the new page so the FormView
refreshes with the wrong value. I also bind the formview on pageload
but that doesn't work either. What am I doing wrong? Here's my
code-behind, followed by the form script...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Not IsNothing(Me.gvwProducts.SelectedValue) Then
Me.fvwCurrentProduct.DataBind()
End If

End Sub

Protected Sub gvwProducts_PageIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
gvwProducts.PageIndexChanged
Me.gvwProducts.SelectedIndex = 0
fvwCurrentProduct.DataBind()
End Sub

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="ViewProducts.aspx.vb"
Inherits="MichaelBaker.JobTracker.UI.ViewProducts" title="Untitled
Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
&nbsp; &nbsp;
<asp:FormView ID="fvwCurrentProduct" runat="server"
DataSourceID="odsCurrentProduct">
<EditItemTemplate>
FileType:
<asp:TextBox ID="FileTypeTextBox" runat="server" Text='<%#
Bind("FileType") %>'>
</asp:TextBox><BR />
AssignedTo:
<asp:TextBox ID="AssignedToTextBox" runat="server"
Text='<%# Bind("AssignedTo") %>'>
</asp:TextBox><BR />
Status:
<asp:TextBox ID="StatusTextBox" runat="server" Text='<%#
Bind("Status") %>'>
</asp:TextBox><BR />
MediaPath:
<asp:TextBox ID="MediaPathTextBox" runat="server" Text='<%#
Bind("MediaPath") %>'>
</asp:TextBox><BR />
JobId:
<asp:TextBox ID="JobIdTextBox" runat="server" Text='<%#
Bind("JobId") %>'>
</asp:TextBox><BR />
ProductStatusId:
<asp:TextBox ID="ProductStatusIdTextBox" runat="server"
Text='<%# Bind("ProductStatusId") %>'>
</asp:TextBox><BR />
ID:
<asp:TextBox ID="IDTextBox" runat="server" Text='<%#
Bind("ID") %>'>
</asp:TextBox><BR />
AttachDate:
<asp:TextBox ID="AttachDateTextBox" runat="server"
Text='<%# Bind("AttachDate") %>'>
</asp:TextBox><BR />
Description:
<asp:TextBox ID="DescriptionTextBox" runat="server"
Text='<%# Bind("Description") %>'>
</asp:TextBox><BR />
User:
<asp:TextBox ID="UserTextBox" runat="server" Text='<%#
Bind("User") %>'>
</asp:TextBox><BR />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
FileType:
<asp:TextBox ID="FileTypeTextBox" runat="server" Text='<%#
Bind("FileType") %>'>
</asp:TextBox><BR />
AssignedTo:
<asp:TextBox ID="AssignedToTextBox" runat="server"
Text='<%# Bind("AssignedTo") %>'>
</asp:TextBox><BR />
Status:
<asp:TextBox ID="StatusTextBox" runat="server" Text='<%#
Bind("Status") %>'>
</asp:TextBox><BR />
MediaPath:
<asp:TextBox ID="MediaPathTextBox" runat="server" Text='<%#
Bind("MediaPath") %>'>
</asp:TextBox><BR />
JobId:
<asp:TextBox ID="JobIdTextBox" runat="server" Text='<%#
Bind("JobId") %>'>
</asp:TextBox><BR />
ProductStatusId:
<asp:TextBox ID="ProductStatusIdTextBox" runat="server"
Text='<%# Bind("ProductStatusId") %>'>
</asp:TextBox><BR />
ID:
<asp:TextBox ID="IDTextBox" runat="server" Text='<%#
Bind("ID") %>'>
</asp:TextBox><BR />
AttachDate:
<asp:TextBox ID="AttachDateTextBox" runat="server"
Text='<%# Bind("AttachDate") %>'>
</asp:TextBox><BR />
Description:
<asp:TextBox ID="DescriptionTextBox" runat="server"
Text='<%# Bind("Description") %>'>
</asp:TextBox><BR />
User:
<asp:TextBox ID="UserTextBox" runat="server" Text='<%#
Bind("User") %>'>
</asp:TextBox><BR />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
FileType:
<asp:Label ID="FileTypeLabel" runat="server" Text='<%#
Bind("FileType") %>'></asp:Label><BR />
AssignedTo:
<asp:Label ID="AssignedToLabel" runat="server" Text='<%#
Bind("AssignedTo") %>'>
</asp:Label><BR />
Status:
<asp:Label ID="StatusLabel" runat="server" Text='<%#
Bind("Status") %>'></asp:Label><BR />
MediaPath:
<asp:Label ID="MediaPathLabel" runat="server" Text='<%#
Bind("MediaPath") %>'></asp:Label><BR />
JobId:
<asp:Label ID="JobIdLabel" runat="server" Text='<%#
Bind("JobId") %>'></asp:Label><BR />
ProductStatusId:
<asp:Label ID="ProductStatusIdLabel" runat="server"
Text='<%# Bind("ProductStatusId") %>'>
</asp:Label><BR />
ID:
<asp:Label ID="IDLabel" runat="server" Text='<%# Bind("ID")
%>'></asp:Label><BR />
AttachDate:
<asp:Label ID="AttachDateLabel" runat="server" Text='<%#
Bind("AttachDate") %>'>
</asp:Label><BR />
Description:
<asp:Label ID="DescriptionLabel" runat="server" Text='<%#
Bind("Description") %>'>
</asp:Label><BR />
User:
<asp:Label ID="UserLabel" runat="server" Text='<%#
Bind("User") %>'></asp:Label><BR />
</ItemTemplate>
</asp:FormView>
<asp:ObjectDataSource ID="odsCurrentProduct" runat="server"
SelectMethod="GetProductById"
TypeName="MichaelBaker.JobTracker.BLL.Products.Pro duct"
UpdateMethod="UpdateProduct">
<UpdateParameters>
<asp:Parameter Name="ProductId" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="gvwProducts"
Name="ProductId" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:GridView ID="gvwProducts" runat="server"
AutoGenerateColumns="False" DataSourceID="odsProducts"
AllowPaging="True" DataKeyNames="ID" SelectedIndex="0">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="ID" HeaderText="Product Id"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="FileType" HeaderText="File Type"
SortExpression="FileType" />
<asp:BoundField DataField="AssignedTo" HeaderText="Assigned
To" SortExpression="AssignedTo" />
<asp:BoundField DataField="Status" HeaderText="Status"
SortExpression="Status" />
<asp:BoundField DataField="MediaPath" HeaderText="Media
Path" SortExpression="MediaPath" />
<asp:BoundField DataField="JobId" HeaderText="Job Id"
SortExpression="JobId" />
<asp:BoundField DataField="AttachDate" HeaderText="Attach
Date" SortExpression="AttachDate" />
<asp:BoundField DataField="Description"
HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="User" HeaderText="User"
ReadOnly="True" SortExpression="User" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="odsProducts" runat="server"
SelectMethod="GetProducts"
TypeName="MichaelBaker.JobTracker.BLL.Products.Pro duct">
</asp:ObjectDataSource>
</asp:Content>

Oct 18 '06 #1
0 4697

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

Similar topics

5
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
4
by: Steve Franks | last post by:
I have this cool nested master page scenario working great. However what is the correct way to be able to access a strongly typed property at the top level master from a content page that has a...
2
by: Jon Spivey | last post by:
Hi, Using VS 2005/VB.net. I need to add a meta description tag and change a stylesheet link from a page based on a master page. Found this article...
3
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
2
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no...
7
by: Just Me | last post by:
Hi I have a master page with a control on it, but I need to set a property of that control from the content. my master page is called Admin.Master and the class is Admin. I have tried this
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
5
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I'm trying to make my code as streamlined as possible, and add CSS file references dynamically when they are required, for example, if a page contains a webcontrol, then the related CSS...
4
by: harijay | last post by:
Hi I am new to writing module and object oriented python code. I am trying to understand namespaces and classes in python. I have the following test case given in three files runner , master and...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.