problems passing data

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
 
T

Troy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top