473,588 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problems passing data

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="Syst em.Data" %>
<%@ import namespace="Syst em.Data.sqlclie nt" %>
<%@ Page Language="vb" Debug="true" Classname="Page 1" %>

<script language="vb" runat="server" ClassName="Sele ctionPage" >

Public ReadOnly Property GridData() As System.Object
Get
' Datasource of Datagrid1 is a data table inside a dataset
Return ddl.SelectedIte m()
End Get
End Property
Sub Page_Load(Sende r As Object, E As EventArgs)
getdata()
End Sub
sub getdata()
Dim MyConnection As SqlConnection = new
sqlConnection(" server=sqlserve r;uid=app;pwd=p assword;databas e=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.Op en()
reader = dr.ExecuteReade r()
While reader.read()
Values.Add(read er.item("au_id" ).ToString())
End While
ddl.DataSource = values
ddl.DataBind()
Myconnection.Cl ose()
reader.close()
end sub

Sub Transfer(ByVal sender As System.Object, ByVal e As System.EventArg s)
Server.Transfer ("page2.aspx ")
End Sub
</script>
<html>
<body>
<form runat="server">
<asp:DropDownLi st id="ddl" runat="Server" />
<br>
<br>
<asp:Button id="Button1" runat="server" OnClick="Transf er" text="Submit"
/>
</form>
</body>
</html>
*************** *************** *************** *************** *******
'Page2.apsx
<%@ Page Language="VB" %>
<%@ Reference Page="page1.asp x" %>
<script runat="server">
Dim objSendingPage As SendingPage

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

receivingddl.Va lue = objSendingPage. GridData
'receivingDG.Da taBind()
End Sub
</script>

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

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

TIA

Nov 17 '05 #1
1 1257
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

"SSW" <fr************ @hotmail.com> wrote in message
news:Oh******** ******@tk2msftn gp13.phx.gbl...
Hope above Attachment helps.

Thanks,

sswalia
MCSD, MCAD, OCA
"Troy" <tr**@ttech.com > wrote in message
news:uj******** ******@TK2MSFTN GP11.phx.gbl...
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="Syst em.Data" %>
<%@ import namespace="Syst em.Data.sqlclie nt" %>
<%@ Page Language="vb" Debug="true" Classname="Page 1" %>

<script language="vb" runat="server" ClassName="Sele ctionPage" >

Public ReadOnly Property GridData() As System.Object
Get
' Datasource of Datagrid1 is a data table inside a dataset
Return ddl.SelectedIte m()
End Get
End Property
Sub Page_Load(Sende r As Object, E As EventArgs)
getdata()
End Sub
sub getdata()
Dim MyConnection As SqlConnection = new
sqlConnection(" server=sqlserve r;uid=app;pwd=p assword;databas e=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.Op en()
reader = dr.ExecuteReade r()
While reader.read()
Values.Add(read er.item("au_id" ).ToString())
End While
ddl.DataSource = values
ddl.DataBind()
Myconnection.Cl ose()
reader.close()
end sub

Sub Transfer(ByVal sender As System.Object, ByVal e As System.EventArg s)
Server.Transfer ("page2.aspx ")
End Sub
</script>
<html>
<body>
<form runat="server">
<asp:DropDownLi st id="ddl" runat="Server" />
<br>
<br>
<asp:Button id="Button1" runat="server" OnClick="Transf er" text="Submit" />
</form>
</body>
</html>
*************** *************** *************** *************** *******
'Page2.apsx
<%@ Page Language="VB" %>
<%@ Reference Page="page1.asp x" %>
<script runat="server">
Dim objSendingPage As SendingPage

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

receivingddl.Va lue = objSendingPage. GridData
'receivingDG.Da taBind()
End Sub
</script>

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

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

TIA


Nov 17 '05 #2

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

Similar topics

1
2038
by: Eric | last post by:
I am trying to figure out a good way to implement a XSLT transformation. Basically my goal is that I want to be able to ouput the following XML in a document: <chart type="pie" width="100" height="100"> <data label="Foo" value="12"/> <data label="Bar" value="15"/> ..... </chart>
9
3150
by: John Calcote | last post by:
I'm not sure is there's a g++ specific newsgroup... g++ is telling me there's a const-related problem with my source code and I just don't see it. Now, I don't know that it means much, but VC7 doesn't see the problem either: ----snip-snip-snip---- #include <string> #include <set>
5
2302
by: Rob Ristroph | last post by:
Hi, It's pretty unhelpful to post "I have a huge piece of code that crashes in strange places, what's the problem?" but that's basically my problem and I really am at my wit's end. The piece of code in question always crashes in an STL operation such as a vector.push_back, but the location of the crash changes as I change how various parts are handled in memory, i.e., make some things dynamically allocated instead of new'd. I know...
2
11889
by: Rick | last post by:
Hi, I'm trying to get a simple UdpClient app working. I've been looking at the MSDN info regarding UdpClient. When I set it up on my own PC and send messages to myself it works OK. If I try to send messages to another PC with another IP address I get multiple exception, the first one being "The requested address is not valid in its context". I get this when I create my UdpClient(iplistener) where iplistener is an IPEndPoint. It doesn't...
3
3663
by: Lonewolf | last post by:
Hi all, I'm having difficulties passing data back to managed class from my native class when the data is generated from within a native thread in the native class itself. I will give the following runtime error, " Attempting to call into managed code without transitioning out first. Do not attempt to run managed code inside low-level native extensibility points, such as the vectored exception handler, since doing so can cause corruption...
16
2516
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client uses IE to talk with a server. The user on the client (IE) sees an ASP net page containing a TextBox. He can write some text in this text box and push a submit button.
2
3262
by: Mike | last post by:
Hi, I am new to C and having problems with the following program. Basically I am trying to read some files, loading data structures into memory for latter searching. I am trying to use structres and arrays of pointers to them. I have gotten the program to compile with gcc on WinXP. If the file i read doesnt have alot of records, it runs thru. But once i add more, it dies. In this program i have 4 files setup to read. The
7
2076
by: Jack | last post by:
Hi, I am having some problems with char and string datatypes. Here is an example int main(){ string str; cout << "enter string: "; cin >str; }
14
3776
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain more why C++/CLI would be better to PInvoke than doing the PInvoke in C#? Because, usually in C# as you already know we use DLLImport and extern
5
1593
by: Simon | last post by:
I have problem with namespaces. I have a program that consumes the web service and has for instance names space nsProgram. In this program I have defined several classes that I use for storing and handling internal information. Than I have web service, that also uses the same classes (I included the file as linked external resource). I included this web service as web reference and used name wsWeb. When I am trying to call the web...
0
7929
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
7860
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,...
0
8222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8354
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7984
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
8223
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6634
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
3883
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1195
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.