saladart
asked on
Passing parameter from one page to another
I am trying to transger the ID field value of the SELECTED row (in the datagrid GRIDVIEWMEETINGS) which is
<asp:HyperLinkField HeaderText="ATTENDEES" NavigateUrl="attendees_lis t.aspx" Target="_parent" Text="VIEW" datanavigateurlfields="ID" DataNavigateUrlFormatStrin g="attende es_list.as px?ID={0}" />
The destination page is not receiving the Parameter "ID" from the source page - selected row.
On the destination page, If I manually put the ID in, I get the expected results - so, I feel that I am not passing the parameter in the proper way.
SOURCE PAGE CODE: .ASPX
<%@ Page Language="VB" MasterPageFile="~/MasterPa ge2.master " AutoEventWireup="false" CodeFile="MeetingCalendar. aspx.vb" Inherits="SALES_CALENDARS_ MeetingCal endar" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Cont entPlaceHo lder1" Runat="Server"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<div style="z-index: 102; left: 168px; width: 384px; position: absolute; top: 0px;
height: 48px">
<asp:Label ID="lblPayrollCalendar" runat="server" BackColor="DarkTurquoise" BorderColor="Silver"
BorderStyle="Inset" Font-Bold="True" Font-Names="Arial Narrow" Font-Size="X-Large"
ForeColor="Navy" Height="34px" Style="left: 24px; vertical-align: middle; position: absolute;
top: 0px; text-align: center" Text="SALES/MARKETING MEETINGS" Width="320px"></asp:Label>
</div>
<div id="daydetail" runat="server" visible="false">
<span id="daydetail_render" runat="server" /> </div>
<asp:GridView ID="GridViewMeetings" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False " BackColor="White" BorderColor="#3366CC" BorderStyle="None"
BorderWidth="1px" CellPadding="4" DataSourceID="GetMeetingIn fo" Style="left: 40px;
position: absolute; top: 48px; font-size: small; font-family: 'Arial Narrow'; z-index: 100;" Width="624px" DataKeyNames="id">
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<Columns>
<asp:HyperLinkField HeaderText="ATTENDEES" NavigateUrl="attendees_lis t.aspx" Target="_parent"
Text="VIEW" datanavigateurlfields="ID" DataNavigateUrlFormatStrin g="attende es_list.as px?ID={0}" />
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
ShowHeader="False" SortExpression="id" Visible="False" />
<asp:BoundField DataField="MEETING" HeaderText="MEETING" SortExpression="MEETING" />
<asp:BoundField DataField="PROMOCODE" HeaderText="PROMOCODE" SortExpression="PROMOCODE" />
<asp:BoundField DataField="CITY" HeaderText="CITY" SortExpression="CITY" />
<asp:BoundField DataField="START" HeaderText="START" SortExpression="START" />
<asp:BoundField DataField="END" HeaderText="END" SortExpression="END" />
<asp:BoundField DataField="COORDINATOR" HeaderText="COORDINATOR" ReadOnly="True" SortExpression="COORDINATO R" />
</Columns>
<RowStyle BackColor="White" ForeColor="#003399" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
</asp:GridView>
<asp:SqlDataSource ID="GetMeetingAttendees" runat="server" ConnectionString="<%$ ConnectionStrings:OCUSOFTC ENTRALConn ectionStri ng %>"
SelectCommand="Intranet_sp _Meeting_G et_Attende es_for_Eve nt" SelectCommandType="StoredP rocedure">
<SelectParameters>
<asp:ControlParameter ControlID="GridViewMeeting s" Name="ID" PropertyName="SelectedValu e" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="GetMeetingInfo" runat="server" ConnectionString="<%$ ConnectionStrings:OCUSOFTC ENTRALConn ectionStri ng %>"
SelectCommand="Intranet_sp _Meeting_G et_Items"
SelectCommandType="StoredP rocedure" >
</asp:SqlDataSource>
</asp:Content>
SOURCE PAGE - CODE BEHIND: .ASPX.VB
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Data.Sql
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports System.Web.Security
Public Class SALES_CALENDARS_MeetingCal endar
Inherits System.Web.UI.Page
'Protected Function SelectedID(ByVal id As Integer) As Integer
' Dim meetid As Integer
' meetid = GridViewMeetings.SelectedI ndex.ToStr ing()
' Return meetid
'End Function
'Protected Sub GridViewMeetings_SelectedI ndexChange d(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridViewMeetings.SelectedI ndexChange d
' 'Label1.Visible = True
' 'Label1.Text = GridViewMeetings.SelectedV alue("ID")
' Session.Add("ID", "ID")
' Server.Transfer("attendees _list.aspx ", True)
'End Sub
Protected Sub GridViewMeetings_SelectedI ndexChangi ng(ByVal sender As Object, ByVal e As System.Web.UI.WebControls. GridViewSe lectEventA rgs) Handles GridViewMeetings.SelectedI ndexChangi ng
Session.Add("ID", "ID")
Server.Transfer("attendees _list.aspx ", True)
End Sub
End Class
The DESTINATION PAGE SOURCE CODE IS:
<%@ Page Language="VB" MasterPageFile="~/MasterPa ge2.master " AutoEventWireup="false" CodeFile="attendees_list.a spx.vb" Inherits="SALES_CALENDARS_ attendees_ list" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Cont entPlaceHo lder1" Runat="Server" EnableViewState="false">
<table border="0" cellpadding="0" cellspacing="0" style="width: 88%; position: static;
height: 100%">
<tr>
<td style="height: 25%">
<asp:Label ID="lblAttendeesList" runat="server" Style="font-weight: bold; font-size: medium;
font-family: 'Arial Narrow'; position: static; text-align: center" Width="624px"></asp:Label> </td>
</tr>
<tr>
<td height="75%" style="text-align: center">
<asp:DetailsView ID="DetailsViewMeetAttende es" runat="server" BackColor="White"
BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="MeetingAtten deesList"
Height="50px" Style="position: static" Width="125px" AutoGenerateRows="False">
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<EditRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<RowStyle BackColor="White" ForeColor="#003399" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
</asp:DetailsView>
<asp:SqlDataSource ID="MeetingAttendeesList" runat="server" ConnectionString="<%$ ConnectionStrings:OCUSOFTC ENTRALConn ectionStri ng %>"
SelectCommand="Intranet_sp _Meeting_G et_Attende es_for_Eve nt" SelectCommandType="StoredP rocedure">
<SelectParameters>
<asp:SessionParameter Name="ID" SessionField="ID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
</asp:Content>
The DESTINATION PAGE CODEBEHIND CODE is
Partial Class SALES_CALENDARS_attendees_ list
Inherits System.Web.UI.Page
Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreLoad
Dim meetid As Integer
meetid = Session.Item("id")
End Sub
End Class
The SQL STORED PROCEDURE FOR THE DESTINATION PAGE IS:
CREATE PROCEDURE Intranet_sp_Meeting_Get_At tendees_fo r_Event
(
@ID int
)
AS
select e.[first name]+' '+e.[last name] EMPLOYEE
from meetingattendees a
inner join employees e on e.emp_id = a.attendee
where a.meeting_id = @ID
GO
What am I missing?
Sean
<asp:HyperLinkField HeaderText="ATTENDEES" NavigateUrl="attendees_lis
The destination page is not receiving the Parameter "ID" from the source page - selected row.
On the destination page, If I manually put the ID in, I get the expected results - so, I feel that I am not passing the parameter in the proper way.
SOURCE PAGE CODE: .ASPX
<%@ Page Language="VB" MasterPageFile="~/MasterPa
<asp:Content ID="Content1" ContentPlaceHolderID="Cont
<div style="z-index: 102; left: 168px; width: 384px; position: absolute; top: 0px;
height: 48px">
<asp:Label ID="lblPayrollCalendar" runat="server" BackColor="DarkTurquoise" BorderColor="Silver"
BorderStyle="Inset" Font-Bold="True" Font-Names="Arial Narrow" Font-Size="X-Large"
ForeColor="Navy" Height="34px" Style="left: 24px; vertical-align: middle; position: absolute;
top: 0px; text-align: center" Text="SALES/MARKETING MEETINGS" Width="320px"></asp:Label>
</div>
<div id="daydetail" runat="server" visible="false">
<span id="daydetail_render" runat="server" /> </div>
<asp:GridView ID="GridViewMeetings" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False
BorderWidth="1px" CellPadding="4" DataSourceID="GetMeetingIn
position: absolute; top: 48px; font-size: small; font-family: 'Arial Narrow'; z-index: 100;" Width="624px" DataKeyNames="id">
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<Columns>
<asp:HyperLinkField HeaderText="ATTENDEES" NavigateUrl="attendees_lis
Text="VIEW" datanavigateurlfields="ID"
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
ShowHeader="False" SortExpression="id" Visible="False" />
<asp:BoundField DataField="MEETING" HeaderText="MEETING" SortExpression="MEETING" />
<asp:BoundField DataField="PROMOCODE" HeaderText="PROMOCODE" SortExpression="PROMOCODE"
<asp:BoundField DataField="CITY" HeaderText="CITY" SortExpression="CITY" />
<asp:BoundField DataField="START" HeaderText="START" SortExpression="START" />
<asp:BoundField DataField="END" HeaderText="END" SortExpression="END" />
<asp:BoundField DataField="COORDINATOR" HeaderText="COORDINATOR" ReadOnly="True" SortExpression="COORDINATO
</Columns>
<RowStyle BackColor="White" ForeColor="#003399" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
</asp:GridView>
<asp:SqlDataSource ID="GetMeetingAttendees" runat="server" ConnectionString="<%$ ConnectionStrings:OCUSOFTC
SelectCommand="Intranet_sp
<SelectParameters>
<asp:ControlParameter ControlID="GridViewMeeting
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="GetMeetingInfo" runat="server" ConnectionString="<%$ ConnectionStrings:OCUSOFTC
SelectCommand="Intranet_sp
SelectCommandType="StoredP
</asp:SqlDataSource>
</asp:Content>
SOURCE PAGE - CODE BEHIND: .ASPX.VB
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Data.Sql
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports System.Web.Security
Public Class SALES_CALENDARS_MeetingCal
Inherits System.Web.UI.Page
'Protected Function SelectedID(ByVal id As Integer) As Integer
' Dim meetid As Integer
' meetid = GridViewMeetings.SelectedI
' Return meetid
'End Function
'Protected Sub GridViewMeetings_SelectedI
' 'Label1.Visible = True
' 'Label1.Text = GridViewMeetings.SelectedV
' Session.Add("ID", "ID")
' Server.Transfer("attendees
'End Sub
Protected Sub GridViewMeetings_SelectedI
Session.Add("ID", "ID")
Server.Transfer("attendees
End Sub
End Class
The DESTINATION PAGE SOURCE CODE IS:
<%@ Page Language="VB" MasterPageFile="~/MasterPa
<asp:Content ID="Content1" ContentPlaceHolderID="Cont
<table border="0" cellpadding="0" cellspacing="0" style="width: 88%; position: static;
height: 100%">
<tr>
<td style="height: 25%">
<asp:Label ID="lblAttendeesList" runat="server" Style="font-weight: bold; font-size: medium;
font-family: 'Arial Narrow'; position: static; text-align: center" Width="624px"></asp:Label>
</tr>
<tr>
<td height="75%" style="text-align: center">
<asp:DetailsView ID="DetailsViewMeetAttende
BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="MeetingAtten
Height="50px" Style="position: static" Width="125px" AutoGenerateRows="False">
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<EditRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<RowStyle BackColor="White" ForeColor="#003399" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
</asp:DetailsView>
<asp:SqlDataSource ID="MeetingAttendeesList" runat="server" ConnectionString="<%$ ConnectionStrings:OCUSOFTC
SelectCommand="Intranet_sp
<SelectParameters>
<asp:SessionParameter Name="ID" SessionField="ID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
</asp:Content>
The DESTINATION PAGE CODEBEHIND CODE is
Partial Class SALES_CALENDARS_attendees_
Inherits System.Web.UI.Page
Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreLoad
Dim meetid As Integer
meetid = Session.Item("id")
End Sub
End Class
The SQL STORED PROCEDURE FOR THE DESTINATION PAGE IS:
CREATE PROCEDURE Intranet_sp_Meeting_Get_At
(
@ID int
)
AS
select e.[first name]+' '+e.[last name] EMPLOYEE
from meetingattendees a
inner join employees e on e.emp_id = a.attendee
where a.meeting_id = @ID
GO
What am I missing?
Sean
ASKER
ethoths,
Applying your recommendation yields the below error when I open the page - it compiles but errors out when I run it...
The HyperLinkField control with a two-way databinding to field id must have an ID.
Sean
Applying your recommendation yields the below error when I open the page - it compiles but errors out when I run it...
The HyperLinkField control with a two-way databinding to field id must have an ID.
Sean
Put an ID on the hyperlink! id="AnythingThatIsUniqueWi llDo"
ASP.Net often complains that some controls dont have an ID even though you don't actually need to refer to the control yourself. It's jus one of the ASP.Net things.
ASP.Net often complains that some controls dont have an ID even though you don't actually need to refer to the control yourself. It's jus one of the ASP.Net things.
ASKER
The ASP:HYPERLINKFIELD control does not have a property of ID....I cannot get it to compile with the ID property in the HYPERLINKFIELD control...
Sean
Sean
ASKER
Ok - I made progress... I had to convert the field (HYPERLINK) into a template field and was able to assign an ID - but, I still have the same problem... It seems like the parameter isn't either being picked up by the destination page (ATTENDEES) or the source page is not sending it...
How would I go about finding out where the breakdown is happening?
Sean
How would I go about finding out where the breakdown is happening?
Sean
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<asp:HyperLinkField HeaderText="ATTENDEES" NavigateUrl="attendees_lis
Text="VIEW" datanavigateurlfields='<%#