using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; namespace FineUIPro.Web.TestRun.DriverGoods { public partial class ShowGoodsModel : PageBase { #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.BindGrid(); } } #endregion #region 数据绑定 /// /// 数据绑定 /// private void BindGrid() { //string[] selectRowId = Grid1.SelectedRowIDArray; //foreach (GridRow row in Grid1.Rows) //{ // if (selectRowId.Contains(row.RowID)) // { // hdIds.Text += row.DataKeys[1].ToString() + ","; // } //} string strSql = @"SELECT * FROM dbo.DriverGoods_GoodsModel C where C.ProjectId = @ProjectId"; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); string id = Request.Params["Ids"]; List ids = new List(); foreach (GridRow row in Grid1.Rows) { if (id.Contains(row.DataKeys[0].ToString())) { ids.Add(row.RowID); } } this.Grid1.SelectedRowIDArray = ids.ToArray(); } #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { this.BindGrid(); } #endregion #region 确定按钮 /// /// 确定按钮 /// /// /// protected void btnAccept_Click(object sender, EventArgs e) { string ids = string.Empty; foreach (string id in Grid1.SelectedRowIDArray) { ids += id + ","; } if (!string.IsNullOrEmpty(ids)) { ids = ids.Substring(0, ids.LastIndexOf(",")); } PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(ids) + ActiveWindow.GetHidePostBackReference()); } #endregion } }