sqldatasourcemain.aspx
来自「csharp课本的源代码」· ASPX 代码 · 共 38 行
ASPX
38 行
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SqlDataSourceMain.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
查看各院系学生姓名: <br />
<br />
<asp:DropDownList ID="dropDownListMain" runat="server" AutoPostBack="True" Font-Size="Medium" OnSelectedIndexChanged="dropDownListMain_SelectedIndexChanged" Width="109px">
<asp:ListItem>请选择院系</asp:ListItem>
<asp:ListItem>计算机</asp:ListItem>
<asp:ListItem>数学</asp:ListItem>
</asp:DropDownList><br />
<br />
<asp:CheckBox ID="checkBoxMain" runat="server" Font-Size="Small" Text="仅查看毕业班学生" /><br />
<br />
<asp:ListBox ID="listBoxMain" runat="server" DataSourceID="sqlDataSourceMain" Height="100px"
Width="100px" DataValueField="name" Font-Size="Medium"></asp:ListBox><br />
<br />
</div>
<asp:SqlDataSource ID="sqlDataSourceMain" runat="server" ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Students.mdf;Integrated Security=True;User Instance=True" ProviderName="System.Data.SqlClient" SelectCommand="Select name,grade from information where department=@department">
<SelectParameters>
<asp:ControlParameter ControlID="dropDownListMain" DefaultValue="SelectedValue" Name="department"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?