怎么实现一个textbox与一个dropdownlist的无刷新联动
怎么实现一个textbox与一个dropdownlist的无刷新联动,最好用c#来写。用textbox的值做为条件在数据库中取值后自动填充到dropdownlist中。谢...
怎么实现一个textbox与一个dropdownlist的无刷新联动,最好用c#来写
。用textbox的值做为条件在数据库中取值后自动填充到dropdownlist中。
谢谢 展开
。用textbox的值做为条件在数据库中取值后自动填充到dropdownlist中。
谢谢 展开
2013-06-09
展开全部
用AJAX控件啊!
把AJAX控件先放好!然后把textbox和dropdownlist都放进去!就好了!
把AJAX控件先放好!然后把textbox和dropdownlist都放进去!就好了!
2013-06-09
展开全部
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 MeetWeb;
public partial class AjaxTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(AjaxTest));
if (!Page.IsPostBack)
{
BindData();
}
}
private void BindData()
{
DataSet ds = new DataSet();
String sql = "Select id,name from test";
try
{
ds = GetDataSet(sql, "test");
this.DropDownList1.DataSource = ds.Tables[0];
this.DropDownList1.DataTextField = "name";
this.DropDownList1.DataValueField = "id";
this.DropDownList1.DataBind();
this.DropDownList1.Attributes.Add("onclick", "areaResult();");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
public static DataSet GetDataSet(string sql,string aa)
{
MeetWeb.SqlDataBase a = new MeetWeb.SqlDataBase("server=localhost\\PMSERVER;uid=sa;pwd=sa;database=test");
DataSet ds = new DataSet();
ds=a.CreateSet(sql, aa);
return ds;
}
[AjaxPro.AjaxMethod]
public DataSet GetCityList(int id)
{
string sql = "select name from test where id='" + id + "'";
return GetDataSet(sql,"test");
}
}
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 MeetWeb;
public partial class AjaxTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(AjaxTest));
if (!Page.IsPostBack)
{
BindData();
}
}
private void BindData()
{
DataSet ds = new DataSet();
String sql = "Select id,name from test";
try
{
ds = GetDataSet(sql, "test");
this.DropDownList1.DataSource = ds.Tables[0];
this.DropDownList1.DataTextField = "name";
this.DropDownList1.DataValueField = "id";
this.DropDownList1.DataBind();
this.DropDownList1.Attributes.Add("onclick", "areaResult();");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
public static DataSet GetDataSet(string sql,string aa)
{
MeetWeb.SqlDataBase a = new MeetWeb.SqlDataBase("server=localhost\\PMSERVER;uid=sa;pwd=sa;database=test");
DataSet ds = new DataSet();
ds=a.CreateSet(sql, aa);
return ds;
}
[AjaxPro.AjaxMethod]
public DataSet GetCityList(int id)
{
string sql = "select name from test where id='" + id + "'";
return GetDataSet(sql,"test");
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-09
展开全部
AJAX这个海
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询