using data from one to page to another

M

mike

hello,

I have pasted my code below. My issue is that I want the use to select an
author from the drop down list and upon doing so i should navigate to
another page and pull the full record. Any ideas?

***********************************************************************
<%@ Page Language ="VB" Debug="True" %>
<%@ Import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>

<script language="VB" runat="server">


Public ReadOnly Property selectedText As String
Get
Return ddl.selecteditem.Text
End Get
End Property


sub page_load(sender as Object, e As EventArgs)
If Not Page.IsPostBack Then
getdata()
end if
end sub

sub getdata()
Dim myconnection as SqlConnection = new
sqlconnection("server=servera;uid=app;pwd=password;database=pubs")
Dim mycommand as SqlCommand = new SqlCommand("Select au_id, au_lname,
au_fname from Authors",myconnection)
Dim MyDatareader as SqlDataReader

myconnection.open()
mydatareader=myCommand.ExecuteReader()
ddl.DataSource = MyDataReader
ddl.DataBind()
MyDataReader.Close()
ddl.Items.Insert(0,"Select an Item")
ddl.SelectedIndex = 0
myconnection.close()
End Sub

Sub displayselection(sender as Object, e as EventArgs)
lblSelection.Text = "You selected the item in position " _
& ddl.SelectedItem.Value _
& " which corresponds to the name " _
& ddl.SelectedItem.Text _
& "."
End Sub

</script>

<html>
<body>
<form runat="server">
<asp:DropDownList id="ddl" runat="server" DataTextField="au_lname"
DataValueField="au_id" />
<br>
<br>
<asp:Button id="Button1" runat="server" OnClick="displayselection"
text="Submit" />
</form>
<p>
<asp:Label id="lblSelection" runat="server" />
</p>

</body>
</html>
 

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

Top