62,072
社区成员
发帖
与我相关
我的任务
分享
protected void datebind()
{
}
//dropdownlist查询
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex == 0)
{
if (RadioButtonList1.SelectedIndex == 0)
{
DataListBind();
}
else
{
Model.RoomState rs = new Model.RoomState();
BLL.BRoomInfo bri = new BLL.BRoomInfo();
rs.RState_State1 = RadioButtonList1.SelectedValue.ToString();
DataSet ds = bri.selectbystate(rs);
PagedDataSource page = new PagedDataSource();
page.DataSource = ds.Tables[0].DefaultView;
page.AllowPaging = true; page.PageSize = 10;
int curpage;
if (Request.QueryString["page"] != null)
{
curpage = Convert.ToInt32(Request.QueryString["page"]);
}
else
{
curpage = 1;
}
page.CurrentPageIndex = curpage - 1;
int totalpage = page.PageCount;
int tnum = page.DataSourceCount;
int eachpage = page.Count;
lblcurpage.Text = "第" + curpage.ToString() + "/" + totalpage.ToString() + "页";
lbltnum.Text = "共:" + tnum.ToString() + "条记录";
if (page.CurrentPageIndex != 0)
{
hlfirst.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(1);
}
if (page.CurrentPageIndex != totalpage - 1)
{
hllast.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(totalpage);
}
if (!page.IsFirstPage)
{
hlpre.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(curpage - 1);
}
if (!page.IsLastPage)
{
hlnext.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(curpage + 1);
}
DataList1.DataSource = page;
DataList1.DataBind();
}
}
else
{
if (RadioButtonList1.SelectedIndex == 0)
{
Model.FloorInfo fl = new Model.FloorInfo();
BLL.BRoomInfo bri = new BLL.BRoomInfo();
fl.Floor_Num1 = Convert.ToInt32(DropDownList1.SelectedValue);
DataSet ds = bri.selectallbyfloor(fl);
PagedDataSource page = new PagedDataSource();
page.DataSource = ds.Tables[0].DefaultView;
page.AllowPaging = true; page.PageSize = 10;
int curpage;
if (Request.QueryString["page"] != null)
{
curpage = Convert.ToInt32(Request.QueryString["page"]);
}
else
{
curpage = 1;
}
page.CurrentPageIndex = curpage - 1;
int totalpage = page.PageCount;
int tnum = page.DataSourceCount;
int eachpage = page.Count;
lblcurpage.Text = "第" + curpage.ToString() + "/" + totalpage.ToString() + "页";
lbltnum.Text = "共:" + tnum.ToString() + "条记录";
if (page.CurrentPageIndex != 0)
{
hlfirst.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(1);
}
if (page.CurrentPageIndex != totalpage - 1)
{
hllast.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(totalpage);
}
if (!page.IsFirstPage)
{
hlpre.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(curpage - 1);
}
if (!page.IsLastPage)
{
hlnext.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(curpage + 1);
}
DataList1.DataSource = page;
DataList1.DataBind();
ds.Tables[0].Dispose();
}
else
{
Model.FloorInfo fl = new Model.FloorInfo();
Model.RoomState rs = new Model.RoomState();
BLL.BRoomInfo bri = new BLL.BRoomInfo();
fl.Floor_Num1 = Convert.ToInt32(DropDownList1.SelectedValue);
rs.RState_State1 = RadioButtonList1.SelectedValue.ToString();
DataSet ds = bri.select(fl, rs);
PagedDataSource page = new PagedDataSource();
page.DataSource = ds.Tables[0].DefaultView;
page.AllowPaging = true;
page.PageSize = 10;
int curpage;
if (Request.QueryString["page"] != null)
{
curpage = Convert.ToInt32(Request.QueryString["page"]);
}
else
{
curpage = 1;
}
page.CurrentPageIndex = curpage - 1;
int totalpage = page.PageCount;
int tnum = ds.Tables[0].Rows.Count;
int eachpage = page.Count;
lblcurpage.Text = "第" + curpage.ToString() + "/" + totalpage.ToString() + "页";
lbltnum.Text = "共:" + tnum.ToString() + "条记录";
if (page.CurrentPageIndex != 0)
{
hlfirst.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(1);
}
if (page.CurrentPageIndex != totalpage - 1)
{
hllast.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(totalpage);
}
if (!page.IsFirstPage)
{
hlpre.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(curpage - 1);
}
if (!page.IsLastPage)
{
hlnext.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(curpage + 1);
}
DataList1.DataSource = page;
DataList1.DataBind();
}
}
}
接上楼using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace website.RoomManager
{
public partial class ManagerRoomDetail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RadionButtonBind();
DataListBind();
DropDownListBind();
}
}
protected void RadionButtonBind()
{
BLL.BRommState brs = new BLL.BRommState();
DataSet ds = brs.selectall();
RadioButtonList1.Items.Add("所有");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string str=ds .Tables [0].Rows [i][1].ToString ();
RadioButtonList1.Items.Add(str);
}
}
protected void DetailsViewBind()
{
Panel1.Visible = true;
Model.RoomInfo ri = new Model.RoomInfo();
BLL.BRoomInfo bri = new BLL.BRoomInfo();
ri.Room_Id1 = roomid;
DataSet ds = bri.selectbyid(ri);
this.DetailsView2.DataSource=ds.Tables[0].DefaultView;
DetailsView2.DataBind();
}
protected void DropDownListBind()
{
BLL.BFloor bfl = new BLL.BFloor();
DataSet ds= bfl.selectall();
DropDownList1.Items.Add("请选择楼层");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string str=ds.Tables [0].Rows [i ][1].ToString ();
DropDownList1.Items.Add(str);
}
}
//类型绑定
protected void TypeBind()
{
BLL.BRoomType brt = new BLL.BRoomType();
DataSet ds= brt.selectalltype();
DropDownList ddl=(DropDownList )DetailsView2 .Rows [1].Cells [1].FindControl ("ddltype");
ddl.Items.Add(typename );
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string str = ds.Tables[0].Rows[i][0].ToString();
ddl.Items.Add(str);
}
}
//根据用户输入绑定楼层
protected void FloorBind()
{
Model.RoomInfo ri = new Model.RoomInfo();
BLL.BFloor bfl = new BLL.BFloor();
TextBox txtbox=(TextBox)DetailsView2.Rows[0].Cells[1].FindControl("txtboxid") ;
if (txtbox .Text =="" )
{
((DropDownList)DetailsView2.Rows[2].Cells[1].FindControl("ddlfloor")).Items.Add("未分配楼层");
}
else
{
ri.Room_Id1 = ((TextBox)(DetailsView2.Rows[0].Cells[1].FindControl("txtboxid"))).Text;
DataSet ds = bfl.selectfloor(ri );
for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
{
string str = ds.Tables[0].Rows[j][0].ToString();
((DropDownList)(DetailsView2.Rows[2].Cells[1].FindControl("ddlfloor"))).Items.Add(str);
}
}
}
//全部绑定
protected void DataListBind()
{
BLL.BRoomInfo emp = new BLL.BRoomInfo();
DataSet ds = emp.selectall();
PagedDataSource page = new PagedDataSource();
page.DataSource = ds.Tables[0].DefaultView;
page.AllowPaging = true; page.PageSize = 10;
int curpage;
if (Request.QueryString["page"] != null)
{
curpage = Convert.ToInt32(Request.QueryString["page"]);
}
else
{
curpage = 1;
}
page.CurrentPageIndex = curpage - 1;
int totalpage = page.PageCount;
int tnum = page.DataSourceCount;
int eachpage = page.Count;
lblcurpage.Text = "第" + curpage.ToString()+"/" + totalpage.ToString() + "页";
lbltnum.Text = "共:" + tnum.ToString() + "条记录";
if (page.CurrentPageIndex != 0)
{
hlfirst.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(1);
}
if (page.CurrentPageIndex !=totalpage -1)
{
hllast .NavigateUrl =Request .CurrentExecutionFilePath +"?page="+Convert .ToString (totalpage );
}
if (!page.IsFirstPage)
{
hlpre.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(curpage - 1);
}
if (!page.IsLastPage )
{
hlnext .NavigateUrl =Request .CurrentExecutionFilePath +"?page="+Convert .ToString (curpage +1);
}
if (page.IsLastPage)
{
hllast.Visible = false;
}
if (page.IsFirstPage)
{
hlfirst.Visible = false;
}
if (curpage > totalpage)
{
page.CurrentPageIndex = 0;
}
DataList1.DataSource = page;
DataList1.DataBind();
ds.Tables[0].Dispose();
}