473,738 Members | 2,009 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
objectdatasourc e. 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 PageIndexChange d 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.EventArg s) Handles Me.Load

If Not IsNothing(Me.gv wProducts.Selec tedValue) Then
Me.fvwCurrentPr oduct.DataBind( )
End If

End Sub

Protected Sub gvwProducts_Pag eIndexChanged(B yVal sender As
Object, ByVal e As System.EventArg s) Handles
gvwProducts.Pag eIndexChanged
Me.gvwProducts. SelectedIndex = 0
fvwCurrentProdu ct.DataBind()
End Sub

<%@ Page Language="VB" MasterPageFile= "~/MasterPage.mast er"
AutoEventWireup ="false" CodeFile="ViewP roducts.aspx.vb "
Inherits="Micha elBaker.JobTrac ker.UI.ViewProd ucts" title="Untitled
Page" %>
<asp:Content ID="Content1" ContentPlaceHol derID="ContentP laceHolder1"
Runat="Server">
&nbsp; &nbsp;
<asp:FormView ID="fvwCurrentP roduct" runat="server"
DataSourceID="o dsCurrentProduc t">
<EditItemTempla te>
FileType:
<asp:TextBox ID="FileTypeTex tBox" runat="server" Text='<%#
Bind("FileType" ) %>'>
</asp:TextBox><BR />
AssignedTo:
<asp:TextBox ID="AssignedToT extBox" runat="server"
Text='<%# Bind("AssignedT o") %>'>
</asp:TextBox><BR />
Status:
<asp:TextBox ID="StatusTextB ox" runat="server" Text='<%#
Bind("Status") %>'>
</asp:TextBox><BR />
MediaPath:
<asp:TextBox ID="MediaPathTe xtBox" runat="server" Text='<%#
Bind("MediaPath ") %>'>
</asp:TextBox><BR />
JobId:
<asp:TextBox ID="JobIdTextBo x" runat="server" Text='<%#
Bind("JobId") %>'>
</asp:TextBox><BR />
ProductStatusId :
<asp:TextBox ID="ProductStat usIdTextBox" runat="server"
Text='<%# Bind("ProductSt atusId") %>'>
</asp:TextBox><BR />
ID:
<asp:TextBox ID="IDTextBox" runat="server" Text='<%#
Bind("ID") %>'>
</asp:TextBox><BR />
AttachDate:
<asp:TextBox ID="AttachDateT extBox" runat="server"
Text='<%# Bind("AttachDat e") %>'>
</asp:TextBox><BR />
Description:
<asp:TextBox ID="Description TextBox" runat="server"
Text='<%# Bind("Descripti on") %>'>
</asp:TextBox><BR />
User:
<asp:TextBox ID="UserTextBox " runat="server" Text='<%#
Bind("User") %>'>
</asp:TextBox><BR />
<asp:LinkButt on ID="UpdateButto n" runat="server"
CausesValidatio n="True" CommandName="Up date"
Text="Update">
</asp:LinkButton>
<asp:LinkButt on ID="UpdateCance lButton" runat="server"
CausesValidatio n="False" CommandName="Ca ncel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplat e>
<InsertItemTemp late>
FileType:
<asp:TextBox ID="FileTypeTex tBox" runat="server" Text='<%#
Bind("FileType" ) %>'>
</asp:TextBox><BR />
AssignedTo:
<asp:TextBox ID="AssignedToT extBox" runat="server"
Text='<%# Bind("AssignedT o") %>'>
</asp:TextBox><BR />
Status:
<asp:TextBox ID="StatusTextB ox" runat="server" Text='<%#
Bind("Status") %>'>
</asp:TextBox><BR />
MediaPath:
<asp:TextBox ID="MediaPathTe xtBox" runat="server" Text='<%#
Bind("MediaPath ") %>'>
</asp:TextBox><BR />
JobId:
<asp:TextBox ID="JobIdTextBo x" runat="server" Text='<%#
Bind("JobId") %>'>
</asp:TextBox><BR />
ProductStatusId :
<asp:TextBox ID="ProductStat usIdTextBox" runat="server"
Text='<%# Bind("ProductSt atusId") %>'>
</asp:TextBox><BR />
ID:
<asp:TextBox ID="IDTextBox" runat="server" Text='<%#
Bind("ID") %>'>
</asp:TextBox><BR />
AttachDate:
<asp:TextBox ID="AttachDateT extBox" runat="server"
Text='<%# Bind("AttachDat e") %>'>
</asp:TextBox><BR />
Description:
<asp:TextBox ID="Description TextBox" runat="server"
Text='<%# Bind("Descripti on") %>'>
</asp:TextBox><BR />
User:
<asp:TextBox ID="UserTextBox " runat="server" Text='<%#
Bind("User") %>'>
</asp:TextBox><BR />
<asp:LinkButt on ID="InsertButto n" runat="server"
CausesValidatio n="True" CommandName="In sert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButt on ID="InsertCance lButton" runat="server"
CausesValidatio n="False" CommandName="Ca ncel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTempl ate>
<ItemTemplate >
FileType:
<asp:Label ID="FileTypeLab el" runat="server" Text='<%#
Bind("FileType" ) %>'></asp:Label><BR />
AssignedTo:
<asp:Label ID="AssignedToL abel" runat="server" Text='<%#
Bind("AssignedT o") %>'>
</asp:Label><BR />
Status:
<asp:Label ID="StatusLabel " runat="server" Text='<%#
Bind("Status") %>'></asp:Label><BR />
MediaPath:
<asp:Label ID="MediaPathLa bel" 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="ProductStat usIdLabel" runat="server"
Text='<%# Bind("ProductSt atusId") %>'>
</asp:Label><BR />
ID:
<asp:Label ID="IDLabel" runat="server" Text='<%# Bind("ID")
%>'></asp:Label><BR />
AttachDate:
<asp:Label ID="AttachDateL abel" runat="server" Text='<%#
Bind("AttachDat e") %>'>
</asp:Label><BR />
Description:
<asp:Label ID="Description Label" runat="server" Text='<%#
Bind("Descripti on") %>'>
</asp:Label><BR />
User:
<asp:Label ID="UserLabel" runat="server" Text='<%#
Bind("User") %>'></asp:Label><BR />
</ItemTemplate>
</asp:FormView>
<asp:ObjectData Source ID="odsCurrentP roduct" runat="server"
SelectMethod="G etProductById"
TypeName="Micha elBaker.JobTrac ker.BLL.Product s.Product"
UpdateMethod="U pdateProduct">
<UpdateParamete rs>
<asp:Paramete r Name="ProductId " Type="Int32" />
</UpdateParameter s>
<SelectParamete rs>
<asp:ControlPar ameter ControlID="gvwP roducts"
Name="ProductId " PropertyName="S electedValue"
Type="Int32" />
</SelectParameter s>
</asp:ObjectDataS ource>
<asp:GridView ID="gvwProducts " runat="server"
AutoGenerateCol umns="False" DataSourceID="o dsProducts"
AllowPaging="Tr ue" DataKeyNames="I D" SelectedIndex=" 0">
<Columns>
<asp:CommandFie ld ShowSelectButto n="True" />
<asp:BoundFie ld DataField="ID" HeaderText="Pro duct Id"
ReadOnly="True" SortExpression= "ID" />
<asp:BoundFie ld DataField="File Type" HeaderText="Fil e Type"
SortExpression= "FileType" />
<asp:BoundFie ld DataField="Assi gnedTo" HeaderText="Ass igned
To" SortExpression= "AssignedTo " />
<asp:BoundFie ld DataField="Stat us" HeaderText="Sta tus"
SortExpression= "Status" />
<asp:BoundFie ld DataField="Medi aPath" HeaderText="Med ia
Path" SortExpression= "MediaPath" />
<asp:BoundFie ld DataField="JobI d" HeaderText="Job Id"
SortExpression= "JobId" />
<asp:BoundFie ld DataField="Atta chDate" HeaderText="Att ach
Date" SortExpression= "AttachDate " />
<asp:BoundFie ld DataField="Desc ription"
HeaderText="Des cription" SortExpression= "Descriptio n" />
<asp:BoundFie ld DataField="User " HeaderText="Use r"
ReadOnly="True" SortExpression= "User" />
</Columns>
</asp:GridView>
<asp:ObjectData Source ID="odsProducts " runat="server"
SelectMethod="G etProducts"
TypeName="Micha elBaker.JobTrac ker.BLL.Product s.Product">
</asp:ObjectDataS ource>
</asp:Content>

Oct 18 '06 #1
0 4744

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

Similar topics

5
2438
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 web part page? Does it take place at the page level? ...or the content area level? 3. Where is the Web Part Manager instantiated? ...in the Master Page? ....Content Page? ...elsewhere?
4
2468
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 nested master page between the content page and the top level master? For example, assume the very top level master is called CompanyWide.master. And the nested master page is called DepartmentA.master, which inherits from CompanyWide master. ...
2
1756
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 http://msdn.microsoft.com/asp.net/reference/design/default.aspx?pull=/library/en-us/dnvs05/html/masterpages.asp#masterpages_topic8 Which seems to suggest it's possible (Listing 11 half way down the page) but the method for adding a meta tag Master.Page.Header.Metadata.Add("Description",...
3
6441
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 BarLabelText. I now have a contentpage "FooBar.aspx", where "Bar.master" is the master page and in the content section has the control "Foo.ascx".
17
3159
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 pages? Kinda sorta a critical point no? Am I missing something? Rob. P.S. the day I find a book that actually is useful rather than just a
2
7021
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 header. I tried to put the link tag in the Master page, but the classes are not recognized in the Content Page. How do I use a StyleSheet with the Content Page? TIA
7
2181
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
9159
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" %> On the Master Page I have a public property exposed: Public Property ErrorMessage() As String Get Return txtError.InnerText End Get
5
2714
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 file is added by the webcontrol. This prevents me having to remember to add the CSS file to the page if I use a certain webcontrol. I have a MasterPage with an array of StyleSheets, and a public function for
4
2965
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 child. I am getting an error within child where in one line it understands variable master.name and in the next line it gives a NameError as given here " print "Reset name now from %s to %s , oldname %s is saved in mastertrash" %...
0
8968
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8787
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9259
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4569
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4824
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
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 we have to send another system
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.