📄 shipmethod_event.ascx
字号:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="C#" runat="server">
string ConnStr;
public string ConnectionString
{
get {return ConnStr; }
set {ConnStr = value;}
}
public void Page_Load(Object Source, EventArgs E)
{
if (!IsPostBack)
{
SqlConnection myConnection;
SqlCommand myCommand;
SqlDataReader myReader;
string SQL;
SQL= "select * from Shippers";
if (ConnStr == "")
ConnStr = ConfigurationSettings.AppSettings["DsnNorthwind"];
myConnection = new SqlConnection(ConnStr);
myConnection.Open();
myCommand = new SqlCommand(SQL, myConnection);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
ShipMethod.Items.Add(new ListItem(myReader["CompanyName"].ToString(), myReader["ShipperID"].ToString()));
}
}
public void ShipMethod_Change(Object Source, EventArgs E)
{
SelectedMethod.Text = "You have selected " + ShipMethod.SelectedItem.Text + " as your shipping method.";
}
</script>
<asp:DropDownList AutoPostBack="true" OnSelectedIndexChanged = "ShipMethod_Change" id="ShipMethod" runat="server"/>
<BR><asp:Label id="SelectedMethod" runat="server"/>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -