473,503 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4735

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

Similar topics

5
2398
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
2451
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
1734
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
6394
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
3134
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
6912
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
2164
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
9118
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
2702
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
2946
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
7093
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
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7348
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...
1
7006
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3166
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.