VB.NET Show an Problem...
I cannot read select i want to method: for example....
I am chose dropdownlist in records, but When click PlaceOrder button, label will display when i chose records....but why display first records???cannot display second or......etc records ???can us tell me, thanks!
this is a WebForm1.aspx.vb :
=============================================
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim myReader As SqlDataReader
Dim sql As String
Dim ConnStr As String
sql = "Select * From Shippers"
ConnStr = "Server=localhost;uid=sa;pwd=frances;database=Northwind"
myConnection = New SqlConnection(ConnStr)
myConnection.Open()
myCommand = New SqlCommand(sql, myConnection)
myReader = myCommand.ExecuteReader()
ShipMethod.DataSource = myReader
ShipMethod.DataBind()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
YouSelected.Text = "You Order will be Delivered vis : " & _
ShipMethod.SelectedItem.Text
End Sub
=============================================
this is a WebForm1.aspx :
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="test.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:label id="Label1" style="Z-INDEX: 101; LEFT: 160px; POSITION: absolute; TOP: 104px" runat="server"
Font-Bold="True">Please Select your delivery method:</asp:label><asp:button id="Button1" style="Z-INDEX: 103; LEFT: 176px; POSITION: absolute; TOP: 144px" runat="server"
Text="Place Order"></asp:button><asp:dropdownlist id="ShipMethod" style="Z-INDEX: 102; LEFT: 416px; POSITION: absolute; TOP: 104px"
DataTextField="CompanyName" DataValueField ="ShipperID" runat="server"></asp:dropdownlist>
<asp:Label id="YouSelected" style="Z-INDEX: 104; LEFT: 160px; POSITION: absolute; TOP: 192px"
runat="server" Width="320px" Height="40px"></asp:Label></form>
</body>
</HTML>