<%@ language="c#" debug="true" %>
<%@ Import NameSpace="System.Data" %>
<%@ Import NameSpace="System.Data.SqlClient" %><script runat="server">
void Page_Load(Object sender, EventArgs e)
{
string sc=ConfigurationSettings.AppSettings["SQLCONNECTIONSTRING"];
SqlConnection conn=new SqlConnection(sc); if(!IsPostBack)
{
string sql="select questiontype from typeinfo";
SqlCommand scmd=new SqlCommand(sql,conn);
conn.Open();
SqlDataReader sdr;
sdr=scmd.ExecuteReader();
ddl.DataSource=sdr;
ddl.DataTextField="questiontype";
ddl.DataValueField="questiontype";
ddl.DataBind();
conn.Close();
} string sql2="select questionid,question from question where questiontype ='"+ddl.SelectedValue+"' ";
SqlCommand scmd2=new SqlCommand(sql2,conn);
conn.Open();
SqlDataReader sdr2;
sdr2=scmd2.ExecuteReader();
ltb.DataSource=sdr2;
ltb.DataTextField="question";
ltb.DataValueField="questionid";
ltb.DataBind();
conn.Close();
}void choose(Object sender, System.EventArgs e)
{
bt1.Text=ltb.SelectedValue;
}
</script><html>
<head>
<title>修改试题</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head> <body bgcolor="#ebebff">
<form active ="modifyquestion.aspx" runat = "server">
<table width="100%" border="0">
<tr> <td width="12%" align="center"><font size="2">题目类型:</font></td>
<td width="88%">
<asp:dropdownlist id="ddl" width="120" runat="server" autopostback="true" /> </font>
</td>
</tr>
<tr>
<td align="center"><font size="2">题目列表:</font></td>
<td>
<asp:listbox id="ltb" width="480" TextMode="MultiLine" Rows="12" runat="server" /> </font>
</td>
</tr>
</table>
<center>
<asp:Button id="bt1" Text ="修改试题" OnClick="choose" runat="server" />
</form>
</body>
</html>代码如上,sdr 帮定到一个dropdownlist,然后根据选择的值查询出符合条件的数据 帮定到listbox,但是提交的时候却死活不能获取在listbox中选择的值,很是郁闷啊
<%@ Import NameSpace="System.Data" %>
<%@ Import NameSpace="System.Data.SqlClient" %><script runat="server">
void Page_Load(Object sender, EventArgs e)
{
string sc=ConfigurationSettings.AppSettings["SQLCONNECTIONSTRING"];
SqlConnection conn=new SqlConnection(sc); if(!IsPostBack)
{
string sql="select questiontype from typeinfo";
SqlCommand scmd=new SqlCommand(sql,conn);
conn.Open();
SqlDataReader sdr;
sdr=scmd.ExecuteReader();
ddl.DataSource=sdr;
ddl.DataTextField="questiontype";
ddl.DataValueField="questiontype";
ddl.DataBind();
conn.Close();
} string sql2="select questionid,question from question where questiontype ='"+ddl.SelectedValue+"' ";
SqlCommand scmd2=new SqlCommand(sql2,conn);
conn.Open();
SqlDataReader sdr2;
sdr2=scmd2.ExecuteReader();
ltb.DataSource=sdr2;
ltb.DataTextField="question";
ltb.DataValueField="questionid";
ltb.DataBind();
conn.Close();
}void choose(Object sender, System.EventArgs e)
{
bt1.Text=ltb.SelectedValue;
}
</script><html>
<head>
<title>修改试题</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head> <body bgcolor="#ebebff">
<form active ="modifyquestion.aspx" runat = "server">
<table width="100%" border="0">
<tr> <td width="12%" align="center"><font size="2">题目类型:</font></td>
<td width="88%">
<asp:dropdownlist id="ddl" width="120" runat="server" autopostback="true" /> </font>
</td>
</tr>
<tr>
<td align="center"><font size="2">题目列表:</font></td>
<td>
<asp:listbox id="ltb" width="480" TextMode="MultiLine" Rows="12" runat="server" /> </font>
</td>
</tr>
</table>
<center>
<asp:Button id="bt1" Text ="修改试题" OnClick="choose" runat="server" />
</form>
</body>
</html>代码如上,sdr 帮定到一个dropdownlist,然后根据选择的值查询出符合条件的数据 帮定到listbox,但是提交的时候却死活不能获取在listbox中选择的值,很是郁闷啊
解决方案 »
- GridView a标签要怎么使用 jquery单击事件
- 编辑器里面内容要过滤图片和截取一定数量文字?
- 【在线】有兄弟用过勇敢者论坛(DoughtyBBS)吗?请教个小问题。谢谢
- C#, .NET, 面试总结,以及WPF的经典电子书
- 有没有工具直接生成NHibernater的XML以及实体类吗??
- 解决给800分(三),绝不食言.
- 急 在线等
- 第一次亲密接触iewebcontrols
- 如何在定制table中动态添加onclick,onmouseover等等事件
- DLL调用的问题
- 求qq风格菜单控件!
- 大家好:我在调试电子商务程序的注册会员页面时,竟然相同的用户名可以注册好几次,请问大家是怎么回事情啊?
要怎么写才正确呢?好烦啊