查询数据时,查询条件绑定在DropDownList里,查询结果显示在Gridview里,当查询条件改变时如何实现静态刷新
6个回答
展开全部
1. <asp:DropDownList ID="ddlEsbName" runat="server" CssClass="more" AutoPostBack="true"
OnSelectedIndexChanged="ddlEsbName_SelectedIndexChanged">
</asp:DropDownList>
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.
<select name="selectesb" id="selectesb" class="more" onchange="selectvalue(selectesb)">
</select>
//页面加载完毕后执行
$(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 = "<option value='0'>所有订购店</option>";
for (var i = 0; i < result.length; i++) {
var companyid = result[i].CompanyId;
var companyname = result[i].CompanyName;
selecthtml += "<option value =" + companyid + ">";
selecthtml += "" + companyname + "";
selecthtml += "</option>";
}
$("#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();
}
两种方法随便哪个都行
OnSelectedIndexChanged="ddlEsbName_SelectedIndexChanged">
</asp:DropDownList>
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.
<select name="selectesb" id="selectesb" class="more" onchange="selectvalue(selectesb)">
</select>
//页面加载完毕后执行
$(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 = "<option value='0'>所有订购店</option>";
for (var i = 0; i < result.length; i++) {
var companyid = result[i].CompanyId;
var companyname = result[i].CompanyName;
selecthtml += "<option value =" + companyid + ">";
selecthtml += "" + companyname + "";
selecthtml += "</option>";
}
$("#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
可以用Ajax一步调用,实现无刷新
也可以用.NET自带的控件实现
放个updatepanel
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
DropDownList和Gridview绑定同一个数据源就会自动实现你说的这个
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ajax
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询