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

Discussion in 'ASP .Net' started by Salman Iqbal, Sep 22, 2003.

  1. Salman Iqbal

    Salman Iqbal Guest

    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>
    ----------------------------------------------------------------------------
    --------------------------------------------------
     
    Salman Iqbal, Sep 22, 2003
    #1
    1. Advertising

  2. 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>


    "Salman Iqbal" <> wrote in message
    news:...
    > 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>
    > --------------------------------------------------------------------------

    --
    > --------------------------------------------------
    >
    >
     
    Dino Chiesa [Microsoft], Sep 22, 2003
    #2
    1. Advertising

  3. Salman Iqbal

    Plato Guest

    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

    "Salman Iqbal" <> wrote in message
    news:...
    > 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>
    > --------------------------------------------------------------------------

    --
    > --------------------------------------------------
    >
    >
     
    Plato, Oct 3, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. macyp
    Replies:
    2
    Views:
    8,442
    MWells
    Jan 26, 2005
  2. Rabbit
    Replies:
    17
    Views:
    1,526
    Rabbit
    Jun 11, 2006
  3. Gabriel Genellina

    Re: How to pass one HTML values to another HTML

    Gabriel Genellina, Apr 2, 2009, in forum: Python
    Replies:
    0
    Views:
    563
    Gabriel Genellina
    Apr 2, 2009
  4. Replies:
    1
    Views:
    595
    John Saunders
    Sep 29, 2008
  5. Robert Cohen
    Replies:
    3
    Views:
    311
    Andrew Durstewitz
    Jul 15, 2003
Loading...

Share This Page