📄 shipmethod.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
public class ShipMethodClass : UserControl
{
// public variables to match the server controls
public DropDownList ShipMethod;
public Label YouSelected;
public Button PlaceOrder;
public void Page_Load(Object Source, EventArgs E)
{
if (!Page.IsPostBack)
{
SqlConnection myConnection;
SqlCommand myCommand;
SqlDataReader myReader;
String SQL;
String ConnStr;
SQL = "select * from Shippers";
ConnStr = ConfigurationSettings.AppSettings["DsnNorthwind"];
myConnection = new SqlConnection(ConnStr);
myConnection.Open();
myCommand = new SqlCommand(SQL, myConnection);
myReader = myCommand.ExecuteReader();
ShipMethod.DataTextField = "CompanyName";
ShipMethod.DataSource = myReader;
ShipMethod.DataBind();
}
}
public void ShipMethod_Change(Object Source, EventArgs E)
{
YouSelected.Text = "Your order will be delivered via " +
ShipMethod.SelectedItem.Text;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -