贴代码,麻烦大家帮忙看看,谢谢。.aspx<script language="javascript" type="text/javascript" defer="defer">
function ShowName(id)
{
var res=top3.GetExpName(parseInt(id)).value;
var ddl=document.getElementById("<%=DropDownList2.UniqueID %>");
ddl.length=0;
if(res)
{
for(var i=0;i<res.length;i++)
{
ddl.options.add(new Option(res[i]));
}
}
}function GetName(name)
{
document.getelementbyid("ExpName").value=document.all.DropDownList2.options[document.all.DropDownList2.selectedIndex].text;
}
</script>
....
<TD class=title-text-h2 height=22>科室
<asp:DropDownList ID="DropDownList1" runat="server" DataTextField="SecName" DataValueField="SecID">
</asp:DropDownList></TD>
<TD class=title-text-h2 height=22>姓名
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem Value=0 Selected="True">请选择医生</asp:ListItem>
</asp:DropDownList><asp:TextBox ID="ExpName" runat="server" Visible="false"></asp:TextBox></TD>
<td> </td>
<TD><asp:ImageButton ID="submit" ImageUrl="~/pic/zjsearch/shosuo_niutu.gif" runat="server" OnClick="Button_Click" /></TD>
</TR></TBODY></TABLE></TD>.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(top3));//注册
if (!Page.IsPostBack)
{
DataTable dt = user.ShowSec();
this.DropDownList1.DataSource = user.ShowSec();
this.DropDownList1.DataTextField = "SecName";
this.DropDownList1.DataValueField = "SecID";
this.DropDownList1.DataBind();
this.DropDownList1.Items.Insert(0, "请选择科室");
this.DropDownList1.Items[0].Selected = true;
this.DropDownList1.Attributes["onchange"] = "ShowName(this.options[selectedIndex].value)";
this.DropDownList2.Attributes.Add("onchange", "GetName()");
}
}
[AjaxPro.AjaxMethod]
public string[] GetExpName(int stateId)
{
DataTable dt = user.ShowExp(stateId).Table;
string[] name = new String[dt.Rows.Count + 1];
name[0] = "请选择医生";
for (int i = 1; i <= dt.Rows.Count; i++)
{
name[i] = dt.Rows[i - 1]["ExpName"].ToString();
}
return name;
}
protected void Button_Click(object sender, EventArgs e)
{
if (this.DropDownList1.SelectedItem.ToString() == "请选择科室" && this.DropDownList2.SelectedItem.ToString() == "请选择医生")
{
Response.Write("<script language=javascript>alert('请选择要查询的条件!');window.close();</script>");
Response.Write("<script language=javascript>window.location.href='Default.aspx';</script>");
}
else
{
DataTable dt = user.ShowExp(this.DropDownList1.SelectedItem.ToString(), this.ExpName.Text.Trim());
int id = int.Parse(dt.Rows[0]["ID"].ToString());
Response.Redirect("~/zjjs/Showexperts.aspx?ShowID=" + id);
}
}
this.ExpName.Text.Trim(),就是取不到值。
function ShowName(id)
{
var res=top3.GetExpName(parseInt(id)).value;
var ddl=document.getElementById("<%=DropDownList2.UniqueID %>");
ddl.length=0;
if(res)
{
for(var i=0;i<res.length;i++)
{
ddl.options.add(new Option(res[i]));
}
}
}function GetName(name)
{
document.getelementbyid("ExpName").value=document.all.DropDownList2.options[document.all.DropDownList2.selectedIndex].text;
}
</script>
....
<TD class=title-text-h2 height=22>科室
<asp:DropDownList ID="DropDownList1" runat="server" DataTextField="SecName" DataValueField="SecID">
</asp:DropDownList></TD>
<TD class=title-text-h2 height=22>姓名
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem Value=0 Selected="True">请选择医生</asp:ListItem>
</asp:DropDownList><asp:TextBox ID="ExpName" runat="server" Visible="false"></asp:TextBox></TD>
<td> </td>
<TD><asp:ImageButton ID="submit" ImageUrl="~/pic/zjsearch/shosuo_niutu.gif" runat="server" OnClick="Button_Click" /></TD>
</TR></TBODY></TABLE></TD>.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(top3));//注册
if (!Page.IsPostBack)
{
DataTable dt = user.ShowSec();
this.DropDownList1.DataSource = user.ShowSec();
this.DropDownList1.DataTextField = "SecName";
this.DropDownList1.DataValueField = "SecID";
this.DropDownList1.DataBind();
this.DropDownList1.Items.Insert(0, "请选择科室");
this.DropDownList1.Items[0].Selected = true;
this.DropDownList1.Attributes["onchange"] = "ShowName(this.options[selectedIndex].value)";
this.DropDownList2.Attributes.Add("onchange", "GetName()");
}
}
[AjaxPro.AjaxMethod]
public string[] GetExpName(int stateId)
{
DataTable dt = user.ShowExp(stateId).Table;
string[] name = new String[dt.Rows.Count + 1];
name[0] = "请选择医生";
for (int i = 1; i <= dt.Rows.Count; i++)
{
name[i] = dt.Rows[i - 1]["ExpName"].ToString();
}
return name;
}
protected void Button_Click(object sender, EventArgs e)
{
if (this.DropDownList1.SelectedItem.ToString() == "请选择科室" && this.DropDownList2.SelectedItem.ToString() == "请选择医生")
{
Response.Write("<script language=javascript>alert('请选择要查询的条件!');window.close();</script>");
Response.Write("<script language=javascript>window.location.href='Default.aspx';</script>");
}
else
{
DataTable dt = user.ShowExp(this.DropDownList1.SelectedItem.ToString(), this.ExpName.Text.Trim());
int id = int.Parse(dt.Rows[0]["ID"].ToString());
Response.Redirect("~/zjjs/Showexperts.aspx?ShowID=" + id);
}
}
this.ExpName.Text.Trim(),就是取不到值。
解决方案 »
- 字符串截取问题
- 问个关于进度条的问题(windform)
- 给一中专学校学生(专业计算机)的开学上一节电脑兴趣课,大家给推荐点课件,只要让增加他们对计算机认识与兴趣.谢谢
- 关于asp.net调用informix存储过程的问题
- HttpContext的问题,求助!
- 最近在研究crystalReport,所以有很多问题需要请教各为了
- 如何用 正则表达式 来实现长度为偶数
- 为什么以下这个代码不能退出程序???
- 这样的功能怎样实现?
- 如何调用模板生成WORD文档,并在适当的段落中进行编辑以生成一个新的文档.
- datagridview CellFormatting改变checkbox式样时候的问题
- 数据库问题
{
document.getelementbyid("ExpName").value=document.all.DropDownList2.options[document.all.DropDownList2.selectedIndex].text;
} 上面的这个函数发错了。
text好像是在可编辑下拉列表才可以获取的吧 忘了
报错是这里,在0处没有任何行。但是我把this.ExpName.Text.Trim()写成”张三“,就可以正常显示。
请大家帮忙看看啊。