问:dropdownlist 中的值在页面中获取不到..用request获取不到价
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="deledanwei.aspx.cs" Inherits="requar_deledanwei" %><!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> <script src="../js/JScript.js" type="text/javascript" ></script>
<script src="../js/JScript2.js" type="text/javascript" ></script>
<script type="text/javascript" >
var xmlhttp;
function createXMLHTTPRequest(){
xmlhttp=false;
if(window.XMLHttpRequest){//Mozilla浏览器
xmlhttp=new XMLHttpRequest();
if(http_request.overrideMimeType){
xmlhttp.overrideMimeType("text/xml");
}
}
else{
try{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
}
function dateRequest()
{
var name=document.getElementById ("DropDownList1");
createXMLHTTPRequest();
xmlhttp.onreadystatechange=handlestatechange;
xmlhttp.open("GET","?name="+name.value,true);
xmlhttp.send(null);
}
function handlestatechange()
{
if(xmlhttp.readystate==4)
{
if(xmlhttp.status==200)
{
document.getElementById ("mydiv").innerHTML=xmlhttp.ResponseText;
}
}
}
</script>
</head>
<body>
<form id="form1" runat ="server" >
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/right3.gif" /><asp:DropDownList
ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div id="mydiv">
</div>
</form>
</body>
</html>using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class requar_deledanwei : System.Web.UI.Page
{
SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.DropDownList1.Attributes.Add("onchange", "return dateRequest();");
listdropdown();
if (name != "")
{
getname(name);
} }
}
public string name
{
get
{
if (Request ["name"] != null && Request ["name"].ToString ()!= "")
{
return Request ["name"]; }
else
{
return "";
}
}
} private void getname(string name)
{
string sql = ConfigurationManager.AppSettings["gzgl"];
con = new SqlConnection(sql);
con.Open();
SqlCommand cmd = new SqlCommand("select id,name,code from information where name='"+name+"'", con);
SqlDataReader sdr = cmd.ExecuteReader();
string s = @"<table cellspacing='0' cellpadding='4' border='0' id='GridView1' style='color:#333333;border-collapse:collapse;'>";
s+="<tr style='color:White;background-color:#990000;font-weight:bold;'>";
s+="<th scope='col'>流水号</th><th scope='col'>代号</th><th scope='col'>城市</th></tr>";
int m = 0;
while (sdr.Read())
{
if (m % 2 == 0)
{
s += "<tr style='color:#333333;background-color:#FFFBD6;'>";
}
else
{
s += "<tr style='color:#333333;background-color:White;'>";
}
m++;
s += "<td>" + sdr["id"] + "</td>";
s += "<td>" + sdr["code"] + "</td>";
s += "<td>" + sdr["name"] + "</td>";
s += "</tr>";
}
s+="</table>";
sdr.Close();
con.Close();
this.Response.Write(s);
Response.End();
}
public DataSet getdate(string sql)
{
string sqlstr = ConfigurationManager.AppSettings["gzgl"];
con = new SqlConnection(sqlstr);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds);
return ds;
}
private void listdropdown()
{
string sql = "select * from information";
DataSet ds = getdate(sql);
this.DropDownList1.DataSource = ds;
this.DropDownList1.DataTextField = "name";
this.DropDownList1.DataValueField = "id";
this.DropDownList1.DataBind();
}}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="deledanwei.aspx.cs" Inherits="requar_deledanwei" %><!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> <script src="../js/JScript.js" type="text/javascript" ></script>
<script src="../js/JScript2.js" type="text/javascript" ></script>
<script type="text/javascript" >
var xmlhttp;
function createXMLHTTPRequest(){
xmlhttp=false;
if(window.XMLHttpRequest){//Mozilla浏览器
xmlhttp=new XMLHttpRequest();
if(http_request.overrideMimeType){
xmlhttp.overrideMimeType("text/xml");
}
}
else{
try{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
}
function dateRequest()
{
var name=document.getElementById ("DropDownList1");
createXMLHTTPRequest();
xmlhttp.onreadystatechange=handlestatechange;
xmlhttp.open("GET","?name="+name.value,true);
xmlhttp.send(null);
}
function handlestatechange()
{
if(xmlhttp.readystate==4)
{
if(xmlhttp.status==200)
{
document.getElementById ("mydiv").innerHTML=xmlhttp.ResponseText;
}
}
}
</script>
</head>
<body>
<form id="form1" runat ="server" >
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/right3.gif" /><asp:DropDownList
ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div id="mydiv">
</div>
</form>
</body>
</html>using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class requar_deledanwei : System.Web.UI.Page
{
SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.DropDownList1.Attributes.Add("onchange", "return dateRequest();");
listdropdown();
if (name != "")
{
getname(name);
} }
}
public string name
{
get
{
if (Request ["name"] != null && Request ["name"].ToString ()!= "")
{
return Request ["name"]; }
else
{
return "";
}
}
} private void getname(string name)
{
string sql = ConfigurationManager.AppSettings["gzgl"];
con = new SqlConnection(sql);
con.Open();
SqlCommand cmd = new SqlCommand("select id,name,code from information where name='"+name+"'", con);
SqlDataReader sdr = cmd.ExecuteReader();
string s = @"<table cellspacing='0' cellpadding='4' border='0' id='GridView1' style='color:#333333;border-collapse:collapse;'>";
s+="<tr style='color:White;background-color:#990000;font-weight:bold;'>";
s+="<th scope='col'>流水号</th><th scope='col'>代号</th><th scope='col'>城市</th></tr>";
int m = 0;
while (sdr.Read())
{
if (m % 2 == 0)
{
s += "<tr style='color:#333333;background-color:#FFFBD6;'>";
}
else
{
s += "<tr style='color:#333333;background-color:White;'>";
}
m++;
s += "<td>" + sdr["id"] + "</td>";
s += "<td>" + sdr["code"] + "</td>";
s += "<td>" + sdr["name"] + "</td>";
s += "</tr>";
}
s+="</table>";
sdr.Close();
con.Close();
this.Response.Write(s);
Response.End();
}
public DataSet getdate(string sql)
{
string sqlstr = ConfigurationManager.AppSettings["gzgl"];
con = new SqlConnection(sqlstr);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds);
return ds;
}
private void listdropdown()
{
string sql = "select * from information";
DataSet ds = getdate(sql);
this.DropDownList1.DataSource = ds;
this.DropDownList1.DataTextField = "name";
this.DropDownList1.DataValueField = "id";
this.DropDownList1.DataBind();
}}
解决方案 »
- gridview这个控件怎么把数据库里的图片路径显示成图片
- .NET Error Message怎么隐藏,或者怎么引向错误页面
- ★【iframe】联手【frameset】出现的【滚动条问题】★※在线等※●已经发第◆10◆个帖子了●
- 特急!如何用c#编写asp.net客户端activex?
- 关于服务器系统和ASP.NET的奇怪问题
- 树形dropdownlist绑定N级例子
- 一个小问题请高手帮帮忙,急ing !!!!!
- 国外服务器,怎么解决乱码问题
- 请教DropDownList的问题?(不好意思,仅有的10分)
- 同一个dll不同版本 的引用问题 !!icsharpcode.sharpziplib.dll 。net高手帮帮忙 在线等
- WEB用户控件的问题?
- aspnet_membership表中的一个问题!
不要在后台写
可以在页面直接写啊
或者动态输出的时候写
<select onchange=""></select>这样的