1.
private void GetDropDown()
{
ddlEsbName.DataSource = kbView.SelectRegCompanyByGroupBy(1);
ddlEsbName.DataTextField = "CompanyName";
ddlEsbName.DataValueField = "CompanyId";
ddlEsbName.DataBind();
ddlEsbName.Items.Insert(0, new ListItem("所有购物吧", "0"));
}
protected void ddlEsbName_SelectedIndexChanged(object sender, EventArgs e)
{
int pageCount = 0;
PublicLib.Web.PageSplit pSplit = new Tlx.PublicLib.Web.PageSplit(Convert.ToInt32(paginalPbOffer.MethodType), Convert.ToInt32(paginalPbOffer.PageSize));
PbOfferInfo[] _lists = kbView.SelectHistoryProductInfo(ddlEsbName.SelectedValue, pSplit.pageSize, pSplit.pageNo, out pSplit.recordCount, out pageCount);
GridviewID.DataSource = _lists;
paginalPbOffer.RecordCount = pSplit.recordCount;
paginalPbOffer.PageSize = pSplit.pageSize;
GridviewID.DataBind();
}
其实这个也可以用ajax请求 例如:
2.
//页面加载完毕后执行
$(document).ready(function () {
$.getJSON("/Post/EsbSelect.aspx?type=kbesbbar&IsSign=0&jsoncallback=?&t=" + new Date().getMilliseconds,
function (jsons) {
if (jsons != null) {
result = jsons;
var selecthtml = "";
for (var i = 0; i < result.length; i++) {
var companyid = result[i].CompanyId;
var companyname = result[i].CompanyName;
selecthtml += "";
}
$("#selectesb").html(selecthtml).val("<%=esbid %>");
}
else {
$("selectesb").hide();
}
});
)
function selectvalue() {
var svalue = document.getElementById("selectesb");
window.location.href = '/Koubei/CurrentPbOffer.aspx?EsbId='+svalue.value;
}
.cs文件
if(!IsPostBack){
if (!string.IsNullOrEmpty(Request.QueryString["EsbId"]))
{
esbid = Request.QueryString["EsbId"];
}
bindActiveInfo(esbid);
}
private void bindActiveInfo(string esbid)
{
int pageCount = 0;
PublicLib.Web.PageSplit pSplit = new Tlx.PublicLib.Web.PageSplit(Convert.ToInt32(paginalPbOffer.MethodType), Convert.ToInt32(paginalPbOffer.PageSize));
PbOfferInfo[] _lists = kbView.SelectCurrentProductInfo(esbid, pSplit.pageSize, pSplit.pageNo, out pSplit.recordCount, out pageCount);
GridviewID.DataSource = _lists;
paginalPbOffer.PageSize = pSplit.pageSize;
paginalPbOffer.RecordCount = pSplit.recordCount;
GridviewID.DataBind();
}
两种方法随便哪个都行
最简单的是用Ajax控件,用UpdatePanel,然后设置它的Trigger也就是触发按钮为DropDownList或者你的查询Button
你在DropDownList绑定一个事件,在其更新的时候更新数据就行了。
如果你想实现这个的话
可以用Ajax一步调用,实现无刷新
也可以用.NET自带的控件实现
放个updatepanel
DropDownList和Gridview绑定同一个数据源就会自动实现你说的这个
ajax