两个相同的DropDownList,在同一个页面,绑定不同的表:
' 这个是绑定的字符数据变量 Cname
DS = CreateDataSet("Select Cname from Course","Course")
drpCourse.DataSource = DS
drpCourse.DataTextField = "Cname"
drpCourse.DataValueField = "Cname"
drpCourse.DataBind()
'这个是绑定的 数字型的变量 pici
DS = CreateDataSet("Select distinct Pici from eWork","Pici")
drpPici.DataSource = DS
drpPici.DataTextField = "Pici"
drpPici.DataValueField = "Pici"
drpPici.DataBind()
-------------------------------------------------------
怎么提交表单后,第二个能正常工作,而第一个始终都只显示第一条记录?
' 这个是绑定的字符数据变量 Cname
DS = CreateDataSet("Select Cname from Course","Course")
drpCourse.DataSource = DS
drpCourse.DataTextField = "Cname"
drpCourse.DataValueField = "Cname"
drpCourse.DataBind()
'这个是绑定的 数字型的变量 pici
DS = CreateDataSet("Select distinct Pici from eWork","Pici")
drpPici.DataSource = DS
drpPici.DataTextField = "Pici"
drpPici.DataValueField = "Pici"
drpPici.DataBind()
-------------------------------------------------------
怎么提交表单后,第二个能正常工作,而第一个始终都只显示第一条记录?
解决方案 »
- 搞过 YxShop_V4.7.1来帮帮忙.
- 自动生成按钮控件,并在动态按钮上单击时,取得控件的坐标值
- 在.ascx里写的LinkButton的事件不能用!?
- [求助]repeater列表的问题
- 我在.net为何不能用到多个表单..各位帮帮忙..
- 请问显示在Datagrid中的数字列如何设置显示格式?
- 我想的到mssql2000一个表的结构和说明,怎么作?
- .net QR二维码生成越界问题
- 根据搜条件实时统计某张表中某几个不重复字段的产品数量查询速度慢问题
- 如何实现这样的图片超链接?
- 狂郁闷的事情。关于键盘事件
- 新闻系统采用静态页面技术后,如果用户要搜索一篇.html文章,怎么查啊??思路是什么??
而第一个下拉列表选择了其它选项后提交后的仍是第一项
<!--作者:-->
<!--时间:2007-5-30-->
<!--程序功能: 教学管理系统 / 学生作业查询--><!-- 本页面是供学生查询提交作业情况之用
统一规定权限字段:Identify:
管理员:1 教师:2 学生:3
假设此时登陆的为学生 2004415515, Identify=3,转到此页面-->
<!-- #include File= "CreateDS.inc" -->
<script language="vb" runat="server">
public xuehao as String '学生的编号
public Identify as Integer'BindList() 指定数据源 ,并连接到DataList控件
sub BindList(strSql as String ,tableName as String)
Dim conn as New OleDbConnection()
Dim cmd as New OleDbCommand()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = " & Server.MapPath("data/qrms.mdb")
conn.open()
cmd.Connection = conn
cmd.CommandText = strSQL
Dim objAdpt as New OleDbDataAdapter(cmd)
Dim DS as New DataSet()
objAdpt.Fill(DS, TableName)
StuEWork.dataSource = DS.Tables(TableName).DefaultView
StuEWork.DataBind()
end sub
sub Page_load( sender as Object ,e as EventArgs)
xuehao = "2004415515" 'request("tid") 或用Session 变量
Identify = 3 'request("Identify") 或用Session 变量
if not identify=3 then
response.Redirect("Login.aspx") '如果不是教师,则转到登陆界面
end if
if Not IsPostBack then
dim sqlStr as String ="Select * from EWork where xuehao='" & xuehao & "'" '进入本界面后则立即显示该学生提交的所有作业
BindList(sqlStr,"EWork")
Dim DS as New DataSet()
'以下 绑定 课程下拉控件的数据源
DS = CreateDataSet("Select Cname from Course","Course")
drpCourse.DataSource = DS
drpCourse.DataTextField = "Cname"
drpCourse.DataValueField = "Cname"
drpCourse.DataBind()
dim DS2 as New DataSet()
'以下 绑定 批次下拉控件的数据源
DS2 = CreateDataSet("Select distinct Pici from eWork","Pici") '返回连接上的数据集
drpPici.DataSource = DS2 '将DataDownList的数据源与DS 连上
drpPici.DataTextField = "Pici" '设置 DataDownList,指明用于提供选项文本的的数据源字段
drpPici.DataValueField = "Pici" '设置 DataDownList,该属性表示指定数据源的 相关数据字段的值
drpPici.DataBind() end if
end sub
'显示教师筛选后的相关的的学生作业信息
sub ShowDetail(sender as Object ,e as EventArgs)
response.Write(request(drpCourse.SelectedItem.Text) & "*****************" & request.(drpPici.SelectedItem.text))
dim sqlStr as String = "select * from EWork where course = '" & drpCourse.SelectedItem.text & "' and Pici = " & cint(drpPici.SelectedItem.text) & "and xuehao ='" & xuehao & "'"
BindList(sqlStr,"EWork")
if StuEWork.Items.Count =0 then
msg.text ="<b>目前第<font color=blue>" & drpPici.SelectedItem.text & "</font>批,<font color=blue>" & drpCourse.SelectedItem.text & "</font>作业你还没有上交 !<b>"
msgPre.text=""
else
msg.text = ""
msgPre.text="<b>以下是您查询的结果:</b>"
end if
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form name="form1" method="post" action="" runat="server">
请输入你要查询的批次和课程:
<p>课程:<asp:DropDownList runat="server" ID="drpCourse"></asp:DropDownList></p>
<p>批次:<asp:DropDownList runat="server" ID="drpPici"></asp:DropDownList> </p>
<br>
<asp:Button ID="tijiao" Text="筛选" OnClick="ShowDetail" runat="server"/> <br>
<p><asp:Label ID="msgPre" runat="server" Text="以下是你所上交的所有作业:"></asp:Label></p>
<asp:DataList runat="server" ID="StuEWork" CellPadding="3" Width="800" border="2" BorderColor="#FF0000" HorizontalAlign="Center" GridLines="Horizontal">
<headerTemplate>
<asp:Table runat="server" Width="800">
<asp:TableRow runat="server">
<asp:tablecell runat="server" width="40">编号</asp:TableCell>
<asp:tablecell runat="server" width="40">姓名</asp:TableCell>
<asp:tablecell runat="server" width="100">学号</asp:TableCell>
<asp:tablecell runat="server" width="120">所属课程</asp:TableCell>
<asp:tablecell runat="server" width="40">批次</asp:TableCell>
<asp:tablecell runat="server" width="80">班级</asp:TableCell>
<asp:tablecell runat="server" width="180">作业文件</asp:TableCell>
<asp:tablecell runat="server" width="180">上传日期</asp:TableCell>
</asp:TableRow> </asp:Table>
</headerTemplate>
<itemtemplate>
<asp:Table runat="server" Width="800">
<asp:TableRow runat="server" HorizontalAlign="Center">
<asp:tablecell runat="server" width="40"><b><%# Container.DataItem("eId")%></b></asp:tablecell>
<asp:tablecell runat="server" width="40"><b><%# Container.DataItem("ename")%></b></asp:tablecell>
<asp:tablecell runat="server" width="100"><b><%# Container.DataItem("xuehao")%></b></asp:tablecell>
<asp:tablecell runat="server" width="120"><b><%# Container.DataItem("course")%></b></asp:tablecell>
<asp:tablecell runat="server" width="40"><b><%# Container.DataItem("Pici")%></b></asp:tablecell>
<asp:tablecell runat="server" width="80"><b><%# Container.DataItem("class")%></b> </asp:tablecell>
<asp:tablecell runat="server" width="180"><asp:HyperLink runat="server" Text='<%# container.DataItem("efile")%>' NavigateUrl='<%# container.DataItem("efile").toString()%>'/></asp:tablecell>
<asp:tablecell runat="server" width="180"><b><%# Container.DataItem("uDate")%></b> </asp:tablecell>
</asp:TableRow> </asp:Table>
</itemtemplate>
</asp:DataList>
<p><asp:Label ID="msg" runat="server" /> </p>
</form>
</body>
</html>
数据结构研究,ASP.NET,计算机网络,Linux等
当选择 全英文的的记录时,如Linux,提交表单后传的是正常的,而有中文的则不传了,请问什么原因?
-----------------------------
不大会啊,就上面的例子,能给出点代码吗?谢谢
不能随便用<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" %>:的ResponseEncoding="gb2312" ,会造成DropDownList 不能成功传送中文。!!