How i can pass the values from one page to another????????

S

Salman Iqbal

Dear Support team

I have binded a list to logins to the dropdownlist control. And Thanks God
it worked fine.

Suppose database structure is like

********************************
ID NAME

1 Salman
2 Richards
3 Marry

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

But my problem is i want to pass the ID to the next page. When
the users click any login for e.g salman, the page should submit and id(for
e.g 1) should be passed to next page.

I don't have any idea... How it can be done???
Will any one help???

Regards
Salman

----------------------------------------------------------------------------
--------------------------------------------------

<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Page Language="vb"%>
<HTML>
<HEAD>
<title>Dropdown Binding</title>
<script runat="server">

Sub Page_load
'if not IsPostBack then

Dim conPubs as SqlConnection
Dim cmdSelect as SqlCommand
Dim dtrAuthors as SqlDataReader

conPubs = New SqlConnection("Server=WIN2K3\OMER; UID=sa; PWD=sa;
database=personal")
conPubs.Open()
cmdSelect = New SqlCommand("Select name from login", conPubs)
dtrAuthors=cmdSelect.ExecuteReader()

dropAuthors.DataSource=dtrAuthors
dropAuthors.DataTextField="name"
dropAuthors.DataBind()

dtrAuthors.Close()
conPubs.Close()

'End if
End Sub

Sub Press(Sender as object, E as EventArgs)
Name.text=dropAuthors.selectedItem.Text
end sub

</script>
</HEAD>

<body MS_POSITIONING="GridLayout">
<TABLE height="206" cellSpacing="0" cellPadding="0" width="101" border="0"
ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="101" height="206">

<form runat="server">
<TABLE height="84" cellSpacing="0" cellPadding="0" width="194"
border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD colSpan="3" height="2"></TD>
<TD colSpan="2" rowSpan="2">
<asp:Button Text="Pick Authors" onclick="Press" Runat="server"
id="Button1"></asp:Button></TD>
</TR>
<TD colSpan="3">
<asp:DropDownList ID="dropAuthors"
Runat="server"></asp:DropDownList></TD>
</TR>
<TR vAlign="top">
<TD colSpan="2" height="20"></TD>
<TD colSpan="2">
<asp:Label id="Label1" runat="server">You have
selected</asp:Label></TD>

<TD>
<asp:Label ID="Name" runat="server"></asp:Label>
</TD>
</TR>
</TABLE>
</form>
</body>

</HTML>
 
D

Dino Chiesa [Microsoft]

There is a type within the System.Web.UI.WebControls called HyperLink - it
may be what you want.

If you want to maually assemble a page with data, you could do something
like the below. On the other hand, ASP.NET ships with a set of Data-bound
controls, and you can directly map data from databases to these Web UI
controls. A Datagrid, for example, may provide a more automatic way of
getting what you want.

-Dino
Microsoft

==========================================================

<%@ Page Language="C#"
Debug="true"
Trace="false"
%>

<script language="C#" runat=server>

public void Page_Load(Object Sender, EventArgs E) {

string[] names= {"Salman", "Richard", "Mary"};
System.Web.UI.HtmlControls.HtmlTableRow R;
System.Web.UI.HtmlControls.HtmlTableCell Cell;
System.Web.UI.WebControls.HyperLink h1;

try {
// the header row in the table
R= new System.Web.UI.HtmlControls.HtmlTableRow();
Cell= new System.Web.UI.HtmlControls.HtmlTableCell("th");
Cell.InnerText= "ID";
R.Cells.Add(Cell);
Cell= new System.Web.UI.HtmlControls.HtmlTableCell("th");
Cell.InnerText= "Name";
R.Cells.Add(Cell);
T1.Rows.Add(R);

for (int i=0; i < names.Length; i++) {
R= new System.Web.UI.HtmlControls.HtmlTableRow();
Cell= new System.Web.UI.HtmlControls.HtmlTableCell("td");
Cell.InnerText= (i+1).ToString();
R.Cells.Add(Cell);
Cell= new System.Web.UI.HtmlControls.HtmlTableCell("td");

h1= new System.Web.UI.WebControls.HyperLink();
h1.NavigateUrl= "page2.aspx?id=" + (i+1).ToString();
h1.Text= names;
h1.ToolTip="dynamically created at " +
System.DateTime.Now.ToString("s");
Cell.Controls.Add(h1);

R.Cells.Add(Cell);
T1.Rows.Add(R);
}

}
catch (System.Exception ex) {
ErrorMsg.Text += "Exception: " +ex;
}

}

</script>

<html>
<head>
<title>Printers </title>
<link rel="stylesheet" href="style/basic.css"/>
</head>
<body>
<asp:label id="ErrorMsg" CssClass="errormsg" runat="server"/>
<h3>Links</h3>
<table id="T1" runat="server" border="1" cellpadding="3" />
</body>
</html>
 
P

Plato

Why don't you use some thing like this ....on the form that opens after the
login page


<%
Dim strUserName
Dim intUserID

strUserName = Request.Form("txtUserName")
intUserID = Request.Form("txtUserID")

%>

txtUserName and txtUserID are both text boxes on your login page. Or in you
case it would be the drop down list box. Just make sure you give the
controls on the login page a name and id.

Search your help on Request.Form it will give you all the info you need...


Some simple asp
 

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

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top