problems passing data

  • Thread starter Thread starter Troy
  • Start date Start date
T

Troy

Hello,

I'd like to pass data between two pages but unable to get code to work. Code
is below and any help is appreciated:


**********************************************************************
'Page1.aspx
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.sqlclient" %>
<%@ Page Language="vb" Debug="true" Classname="Page1" %>

<script language="vb" runat="server" ClassName="SelectionPage" >

Public ReadOnly Property GridData() As System.Object
Get
' Datasource of Datagrid1 is a data table inside a dataset
Return ddl.SelectedItem()
End Get
End Property


Sub Page_Load(Sender As Object, E As EventArgs)
getdata()
End Sub


sub getdata()
Dim MyConnection As SqlConnection = new
sqlConnection("server=sqlserver;uid=app;pwd=password;database=pubs")
Dim Sql as string = "Select au_id, au_lname, au_fname from Authors"
Dim dr as New SQLCommand(sql, Myconnection)
Dim reader as sqldatareader
Dim Values as ArrayList = new ArrayList()

Myconnection.Open()
reader = dr.ExecuteReader()
While reader.read()
Values.Add(reader.item("au_id").ToString())
End While
ddl.DataSource = values
ddl.DataBind()
Myconnection.Close()
reader.close()
end sub

Sub Transfer(ByVal sender As System.Object, ByVal e As System.EventArgs)
Server.Transfer("page2.aspx")
End Sub


</script>


<html>
<body>
<form runat="server">
<asp:DropDownList id="ddl" runat="Server" />
<br>
<br>
<asp:Button id="Button1" runat="server" OnClick="Transfer" text="Submit"
/>


</form>
</body>
</html>
*******************************************************************
'Page2.apsx
<%@ Page Language="VB" %>
<%@ Reference Page="page1.aspx" %>
<script runat="server">
Dim objSendingPage As SendingPage

Sub Page_Load()
If Not IsPostBack Then
objSendingPage = CType(context.Handler, SendingPage)
End If

receivingddl.Value = objSendingPage.GridData
'receivingDG.DataBind()
End Sub
</script>

<html>
<body>
<form id="Form1" method="post" runat="server">
<b>Visiting Page2.aspx</b>
<asp:lable id="receivingDdl" runat="server" />
</form>
</body>
</html>

******************************************************************

TIA
 
Hi sswalia,

I really appreciate your help but the code your forwarded is in c# and I'm
trying to get going on vb.net. Any chance you can switch language and assist
me with the vb code?

thanks
Troy
 
Back
Top