情况:当在asp:DropDownLis点击选取其中的一个值来响应datalist的值。

<form id="form1" runat="server">
<div>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:examConnectionString2 %>" SelectCommand="SELECT * FROM [Students]"></asp:SqlDataSource>

//DropDownList连接SqlDataSource2

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
DataTextField="StudentName" DataValueField="StudentNo" AutoPostBack="True">

</asp:DropDownList>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:examConnectionString %>"
SelectCommand="select sub.SubjectNo,SubjectName,sub.SubjectKind,sub.Credit,sc.Score from Subjects sub,Score sc where sc.StudentNo = @StudentNo and sc.SubjectNo=sub.SubjectNo">
<SelectParameters>
//通过SqlDataSource1连接DropDownList
<asp:ControlParameter ControlID="DropDownList1" DefaultValue="1" Name="StudentNo" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>

//datalist连接SqlDataSource1

<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
<HeaderTemplate>
<table id="tblist">
<tr>
<th>课程编号</th>
<th>课程名</th>
<th>课程类别</th>
<th>学分</th>
<th>成绩</th>

</tr>
</HeaderTemplate>
<ItemTemplate>

<tr>
<td>
<asp:Label ID="SubjectNoLabel" runat="server" Text='<%# Eval("SubjectNo") %>' />
</td>
<td>
<asp:Label ID="SubjectNameLabel" runat="server" Text='<%# Eval("SubjectName") %>' />
</td>
<td>
<asp:Label ID="SubjectKindLabel" runat="server" Text='<%# Eval("SubjectKind") %>' />
</td>
<td>
<asp:Label ID="CreditLabel" runat="server" Text='<%# Eval("Credit") %>' />
</td>
<td>
<asp:Label ID="ScoreLabel" runat="server" Text='<%# Eval("Score") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:DataList>

</div>
</form>
</body>
</html>

最新文章

  1. Repository 仓储,你的归宿究竟在哪?(二)-这样的应用层代码,你能接受吗?
  2. ANdroid Studio查看debug SHA1
  3. 怎样设置才能允许外网访问MySQL
  4. Silverlight:针式打印机文字模糊的改善办法
  5. Android Studio开发RecyclerView遇到的各种问题以及解决
  6. Ubuntu14.04 Kylin下 GO语言环境搭建
  7. 学习C++ Primer 的个人理解(一)
  8. fedora安装postgresql
  9. 浅谈inline-block
  10. SQL 2008 如何配置远程连接
  11. GNU名称解析
  12. 实例了解js面向对象的封装和继承等特点
  13. git链接到远程github上
  14. Echarts中graph类型的运用求教
  15. GTP+SDI工程播出部分思路整理(2)
  16. python 函数返回值笔记
  17. opp小节
  18. 3,ThreadGroup 的使用场景以及用法
  19. layui 时间插件laydate ,取消回调
  20. python set_index与reset_index的妙用

热门文章

  1. php面试的那些“黑话”
  2. 5.azkaban权限管理
  3. Thunder团队第三周 - Scrum会议6
  4. Thunder团队第二周 - Scrum会议2
  5. c# dllimport
  6. PAT1024 强行用链表写了一发。
  7. Python 零碎信息-基础 01
  8. jsp连接MYSQL数据库教程(文字+图)
  9. 敏捷冲刺Day2
  10. django设置首页