我设置了刷新 页面打开的时候不会显示数据 只有点击刷新的时候显示
//添加查询页面
/// <summary>
/// 条件查选
/// </summary>
/// <param name="biz_event">实体类</param>
/// <param name="btnType">查询类型 0全部查询,1条件查询</param>
/// <returns></returns>
public ActionResult _CompassionsGrid(biz_Compassions biz_Compassions,string btnType)
{
var biz_compassions = db.biz_Compassions.Include(b => b.biz_CompassionType).Include(b=>b.biz_Regions);
if (btnType == "0") {
return PartialView("_CompassionsGrid",biz_compassions);
}
if (string.IsNullOrEmpty(biz_Compassions.CompassionNo) != true) {
biz_compassions = biz_compassions.Where(m=>m.CompassionNo.Contains(biz_Compassions.CompassionNo));
}
if (biz_Compassions.CompassionTypeID != null) {
biz_compassions = biz_compassions.Where(m => m.CompassionTypeID == biz_Compassions.CompassionTypeID);
}
if (biz_Compassions.RegionID != null)
{
biz_compassions = biz_compassions.Where(m => m.RegionID == biz_Compassions.RegionID);
}
return PartialView("_CompassionsGrid", biz_compassions);
}
------解决方案--------------------问题?????
------解决方案--------------------你在Page_load世纪里面,增加
if(!IsPostBack)
{
绑定数据到datagrid
}
这段代码防止自动刷新时执行数据绑定;
当点击刷新button的时候,直接执行 绑定数据到datagrid 代码。
------解决方案--------------------