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">
<aspropDownList ID="dropAuthors"
Runat="server"></aspropDownList></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>
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">
<aspropDownList ID="dropAuthors"
Runat="server"></aspropDownList></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>