/// <summary> /// Use for displaying out a data table by gridview /// </summary> /// <param name="gridview"></param> /// <param name="str_caption">caption of gridview</param> /// <param name="ds">DataSet</param> protected void bindDataSource(GridView gridview, string str_caption, DataSet ds) { bool flag = true; if (ds != null) { if (ds.Tables[0].Rows.Count == 0) { flag = false; sql.getNullDataSet(ds); } //By Lhy 20110512 ITEM18 DEL Start //gridview.Width = Unit.Pixel(260); //By Lhy 20110512 ITEM18 DEL End gridview.AutoGenerateColumns = false; //BY lhy 20110511 DEL Start; // gridview.AllowPaging = true; //BY lhy 20110511 DEL End; //BY lhy 20110511 ADD Start; gridview.AllowPaging = false; //BY lhy 20110511 ADD End; gridview.Visible = true; for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.Width = 200; bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.Wrap = false; gridview.Columns.Add(bf); } CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gridview.Columns.Add(cf_Delete); gridview.AllowSorting = true; //By Lhy 20110512 ITEM18 DEL End //gridview.Caption = str_caption; //gridview.CaptionAlign = TableCaptionAlign.Top; //By Lhy 20110512 ITEM18 DEL End gridview.DataSource = ds.Tables[0]; gridview.DataBind(); gridview.Columns[0].Visible = false; gridview.Columns[gridview.Columns.Count - 1].Visible = flag; if (getRoleID(getRole()) != "0") gridview.Columns[gridview.Columns.Count - 1].Visible = false; } }
protected void bindDataSource(DataSet ds_channel) { bool notNullFlag = true; if (ds_channel.Tables[0].Rows.Count == 0) { notNullFlag = false; sql.getNullDataSet(ds_channel); } gv_channel.Width = Unit.Pixel(600); gv_channel.AutoGenerateColumns = false; //By Wsy 20110512 ITEM 18 DEL Start //gv_channel.AllowPaging = true; //By Wsy 20110512 ITEM 18 DEL End //By Wsy 20110512 ITEM 18 ADD Start gv_channel.AllowPaging = false; //By Wsy 20110512 ITEM 18 ADD End gv_channel.Visible = true; gv_channel.HeaderStyle.Wrap = false; for (int i = 0; i < ds_channel.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds_channel.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds_channel.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; bf.ReadOnly = true; //By Wsy 20110512 ITEM 18 ADD Start bf.ItemStyle.Width = 500; //By Wsy 20110512 ITEM 18 ADD End bf.ControlStyle.Width = bf.ItemStyle.Width; gv_channel.Columns.Add(bf); } CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv_channel.Columns.Add(cf_Delete); gv_channel.AllowSorting = true; gv_channel.DataSource = ds_channel.Tables[0]; gv_channel.DataBind(); gv_channel.Columns[0].Visible = false; gv_channel.Columns[gv_channel.Columns.Count - 1].Visible = notNullFlag; if (getRoleID(getRole()) != "0") { gv_channel.Columns[gv_channel.Columns.Count - 1].Visible = false; } lbtn_channel.Visible = true; }
/// <summary> /// bindDataSource /// </summary> /// <param name="gridview"></param> /// <param name="str_caption"></param> /// <param name="ds"></param> /// <param name="sel"></param> /// protected void bindDataSource(GridView gridview, string str_caption, DataSet ds, bool sel) { bool bflag = true; if (ds.Tables[0].Rows.Count == 0) { bflag = false; sql.getNullDataSet(ds); } gridview.Width = Unit.Pixel(370); gridview.AutoGenerateColumns = false; gridview.AllowPaging = false; gridview.Visible = true; for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString(); bf.ItemStyle.Width = 200; bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; gridview.Columns.Add(bf); } CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gridview.Columns.Add(cf_Delete); gridview.Caption = str_caption; gridview.CaptionAlign = TableCaptionAlign.Top; gridview.AllowSorting = true; gridview.DataSource = ds.Tables[0]; gridview.DataBind(); gridview.Columns[0].Visible = false; gridview.Columns[gridview.Columns.Count - 1].Visible = bflag; }
protected void CreateInvoicedSalesGrid(String grid_id, DataTable data) { // Declare new grid GridView newGrid = new GridView(); newGrid.ID = grid_id; // Behaviours newGrid.AllowSorting = true; newGrid.AutoGenerateColumns = false; newGrid.AutoGenerateEditButton = false; newGrid.EnableViewState = false; // Formatting newGrid.HeaderStyle.BackColor = Util.ColourTryParse("#444444"); newGrid.HeaderStyle.ForeColor = Color.White; newGrid.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; newGrid.HeaderStyle.Font.Size = 8; newGrid.RowStyle.HorizontalAlign = HorizontalAlign.Center; newGrid.RowStyle.BackColor = Util.ColourTryParse("#f0f0f0"); newGrid.AlternatingRowStyle.BackColor = Util.ColourTryParse("#b0c4de"); newGrid.RowStyle.CssClass = "gv_hover"; newGrid.CssClass = "BlackGridHead"; newGrid.BorderWidth = 1; newGrid.CellPadding = 2; newGrid.Width = 1278; newGrid.ForeColor = Color.Black; newGrid.Font.Size = 7; newGrid.Font.Name = "Verdana"; // Grid Event Handlers newGrid.RowDataBound += new GridViewRowEventHandler(gv_inv_RowDataBound); newGrid.Sorting += new GridViewSortEventHandler(gv_Sorting); // Define Columns //0 CommandField commandField = new CommandField(); commandField.ShowEditButton = true; commandField.ShowDeleteButton = false; commandField.ShowCancelButton = false; commandField.ItemStyle.BackColor = Color.White; commandField.ButtonType = System.Web.UI.WebControls.ButtonType.Image; commandField.EditImageUrl = "~\\images\\icons\\gridview_edit.png"; commandField.CancelText = String.Empty; commandField.EditText = String.Empty; commandField.UpdateText = String.Empty; commandField.HeaderText = String.Empty; commandField.ItemStyle.Width = 16; newGrid.Columns.Add(commandField); //1 BoundField ms_id = new BoundField(); ms_id.DataField = "MediaSaleID"; newGrid.Columns.Add(ms_id); //2 BoundField date_added = new BoundField(); date_added.HeaderText = "Added"; date_added.DataField = "DateAdded"; date_added.SortExpression = "DateAdded"; date_added.DataFormatString = "{0:dd/MM/yyyy}"; date_added.ItemStyle.Width = 68; newGrid.Columns.Add(date_added); //3 BoundField friendlyname = new BoundField(); friendlyname.HeaderText = "Rep"; friendlyname.DataField = "Rep"; friendlyname.SortExpression = "Rep"; newGrid.Columns.Add(friendlyname); //4 BoundField client = new BoundField(); client.HeaderText = "Client"; client.DataField = "Client"; client.SortExpression = "Client"; client.ItemStyle.BackColor = Color.Plum; client.ItemStyle.Width = 170; newGrid.Columns.Add(client); //5 BoundField agency = new BoundField(); agency.HeaderText = "Agency"; agency.SortExpression = "Agency"; agency.DataField = "Agency"; agency.ItemStyle.Width = 170; newGrid.Columns.Add(agency); //6 BoundField sale_info = new BoundField(); sale_info.HeaderText = "Sale Info"; sale_info.ItemStyle.Width = 55; newGrid.Columns.Add(sale_info); //7 BoundField size = new BoundField(); size.HeaderText = "Size"; size.DataField = "Size"; newGrid.Columns.Add(size); //8 BoundField channel = new BoundField(); channel.HeaderText = "Channel"; channel.DataField = "Channel"; newGrid.Columns.Add(channel); //9 BoundField country = new BoundField(); country.HeaderText = "Country"; country.DataField = "Country"; newGrid.Columns.Add(country); //10 BoundField media_type = new BoundField(); media_type.HeaderText = "Media"; media_type.DataField = "MediaType"; newGrid.Columns.Add(media_type); //11 BoundField start_date = new BoundField(); start_date.HeaderText = "Starts"; start_date.DataField = "StartDate"; start_date.SortExpression = "StartDate"; start_date.DataFormatString = "{0:dd/MM/yyyy}"; start_date.ItemStyle.Width = 68; newGrid.Columns.Add(start_date); //12 BoundField end_date = new BoundField(); end_date.HeaderText = "Ends"; end_date.DataField = "EndDate"; end_date.SortExpression = "EndDate"; end_date.DataFormatString = "{0:dd/MM/yyyy}"; end_date.ItemStyle.Width = 68; newGrid.Columns.Add(end_date); //13 HyperLinkField contact = new HyperLinkField(); contact.HeaderText = "Contact"; contact.DataTextField = "sale_contact"; contact.SortExpression = "sale_contact"; contact.ItemStyle.Width = 130; newGrid.Columns.Add(contact); //14 BoundField email = new BoundField(); email.HeaderText = "E-mail"; email.SortExpression = "sale_email"; email.DataField = "sale_email"; newGrid.Columns.Add(email); //15 BoundField tel = new BoundField(); tel.HeaderText = "Tel"; tel.SortExpression = "sale_tel"; tel.DataField = "sale_tel"; newGrid.Columns.Add(tel); //16 BoundField units = new BoundField(); units.HeaderText = "Units"; units.DataField = "Units"; units.SortExpression = "Units"; units.ItemStyle.Width = 60; newGrid.Columns.Add(units); //17 BoundField unit_price = new BoundField(); unit_price.HeaderText = "Unit Price"; unit_price.DataField = "UnitPrice"; unit_price.SortExpression = "UnitPrice"; unit_price.ItemStyle.Width = 60; newGrid.Columns.Add(unit_price); //18 BoundField discount = new BoundField(); discount.HeaderText = "Discount"; discount.DataField = "Discount"; discount.SortExpression = "Discount"; discount.ItemStyle.Width = 50; newGrid.Columns.Add(discount); //19 BoundField discount_type = new BoundField(); discount_type.DataField = "DiscountType"; newGrid.Columns.Add(discount_type); //20 BoundField price = new BoundField(); price.HeaderText = "Price"; price.DataField = "Price"; price.SortExpression = "Price"; price.ItemStyle.Width = 68; newGrid.Columns.Add(price); //21 BoundField outstanding = new BoundField(); outstanding.HeaderText = "Outstanding"; outstanding.DataField = "Outstanding"; outstanding.SortExpression = "Outstanding"; outstanding.ItemStyle.Width = 68; newGrid.Columns.Add(outstanding); //22 BoundField date_paid = new BoundField(); date_paid.HeaderText = "Date Paid"; date_paid.DataField = "DatePaid"; date_paid.SortExpression = "DatePaid"; date_paid.DataFormatString = "{0:dd/MM/yyyy}"; date_paid.ItemStyle.Width = 68; newGrid.Columns.Add(date_paid); //23 BoundField invoice = new BoundField(); invoice.HeaderText = "Invoice"; invoice.DataField = "Invoice"; invoice.SortExpression = "Invoice"; invoice.ItemStyle.Width = 70; newGrid.Columns.Add(invoice); //24 BoundField s_notes = new BoundField(); s_notes.HeaderText = "SN"; s_notes.SortExpression = "SaleNotes"; s_notes.DataField = "SaleNotes"; s_notes.ItemStyle.Width = 16; newGrid.Columns.Add(s_notes); //25 BoundField f_notes = new BoundField(); f_notes.HeaderText = "FN"; f_notes.SortExpression = "FinanceNotes"; f_notes.DataField = "FinanceNotes"; f_notes.ItemStyle.Width = 16; newGrid.Columns.Add(f_notes); //26 BoundField msp_id = new BoundField(); msp_id.DataField = "MediaSalePaymentID"; newGrid.Columns.Add(msp_id); //27 BoundField cancelled = new BoundField(); cancelled.DataField = "IsCancelled"; newGrid.Columns.Add(cancelled); //28 BoundField contact_details = new BoundField(); contact_details.DataField = "contact"; contact_details.HtmlEncode = false; // encoded manually newGrid.Columns.Add(contact_details); // Add grid to page div_invoiced.Controls.Add(newGrid); // Bind newGrid.DataSource = data; newGrid.DataBind(); }
private void data_gridVendedor() { tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL(); tb_cxc_evalcred BE = new tb_cxc_evalcred(); DataTable dt = new DataTable(); switch (cmbvendedor.SelectedValue) { case "01": BE.vendorid = txt_busqueda02.Text.Trim().ToUpper(); break; case "02": BE.vendorname = txt_busqueda02.Text.Trim().ToUpper(); break; default: //** break; } try { //Eliminar Columnas Actuales(Opcional): dgb_vendedor.Columns.Clear(); dgb_vendedor.Width = 535; //Objeto Columna: CommandField image; //Crear Columna: image = new CommandField(); image.ButtonType = ButtonType.Image; image.SelectImageUrl = "~/Images/go-search.png"; image.ShowSelectButton = true; image.ItemStyle.Width = 10; image.ItemStyle.Wrap = true; dgb_vendedor.Columns.Add(image); BoundField DDNNI; DDNNI = new BoundField(); DDNNI.DataField = "vendorid"; DDNNI.HeaderText = "CODIGO"; DDNNI.ItemStyle.Width = 50; dgb_vendedor.Columns.Add(DDNNI); BoundField NOMBR; NOMBR = new BoundField(); NOMBR.DataField = "vendorname"; NOMBR.HeaderText = "VENDEDOR"; NOMBR.ItemStyle.Width = 250; dgb_vendedor.Columns.Add(NOMBR); BE.filtro = "2"; dt = BL.GetAll_Filtro(Session["ssEmpresaID"].ToString(), BE).Tables[0]; if (dt.Rows.Count > 0) { dgb_vendedor.DataSource = dt; dgb_vendedor.DataBind(); dgb_vendedor.Visible = true; } } catch (Exception ex) { throw ex;// ClientMessage(ex.Message); } }
private void BindGrid() { BoundField theCol0 = new BoundField(); theCol0.HeaderText = "PatientId"; theCol0.DataField = "Ptn_pk"; theCol0.ItemStyle.CssClass = "textstyle"; grdPClassification.Columns.Add(theCol0); BoundField theCol1 = new BoundField(); theCol1.HeaderText = "ARTSponsorID"; theCol1.DataField = "ARTSponsorID"; theCol1.ItemStyle.CssClass = "textstyle"; grdPClassification.Columns.Add(theCol1); BoundField theCol2 = new BoundField(); theCol2.HeaderText = "Classification"; theCol2.DataField = "Name"; theCol2.SortExpression = "Name"; theCol2.ItemStyle.CssClass = "textstyle"; theCol2.ReadOnly = true; grdPClassification.Columns.Add(theCol2); BoundField theCol3 = new BoundField(); theCol3.HeaderText = "Visit Date:"; theCol3.DataField = "VisitDate"; theCol3.SortExpression = "VisitDate"; theCol3.ItemStyle.CssClass = "textstyle"; theCol3.ReadOnly = true; grdPClassification.Columns.Add(theCol3); BoundField theCol4 = new BoundField(); theCol4.HeaderText = "Location"; theCol4.DataField = "LocationID"; theCol4.SortExpression = "LocationID"; theCol4.ItemStyle.CssClass = "textstyle"; theCol4.ReadOnly = true; grdPClassification.Columns.Add(theCol4); BoundField theCol5 = new BoundField(); theCol5.HeaderText = "Visit_pk"; theCol5.DataField = "Visit_pk"; theCol5.SortExpression = "Visit_pk"; theCol5.ItemStyle.CssClass = "textstyle"; theCol5.ReadOnly = true; grdPClassification.Columns.Add(theCol5); if (Authentiaction.HasFunctionRight(ApplicationAccess.PatientClassification, FunctionAccess.Delete, (DataTable)Session["UserRight"]) == true && Session["lblpntstatus"].ToString() != "1") { CommandField objfield = new CommandField(); objfield.ButtonType = ButtonType.Link; objfield.DeleteText = "<img src='../Images/del.gif' alt='Delete this' border='0' />"; objfield.ShowDeleteButton = true; grdPClassification.Columns.Add(objfield); } grdPClassification.DataBind(); grdPClassification.Columns[0].Visible = false; grdPClassification.Columns[1].Visible = false; grdPClassification.Columns[4].Visible = false; grdPClassification.Columns[5].Visible = false; }
private void data_gridArticulo() { tb_pt_articuloBL BL = new tb_pt_articuloBL(); tb_pt_articulo BE = new tb_pt_articulo(); DataTable dt = new DataTable(); BE.articidold = txt_articidold.Text.ToUpper(); switch (cbo_filtro.SelectedValue) { case "01": BE.articidold = txt_filter.Text.Trim().ToUpper(); break; case "02": BE.articname = txt_filter.Text.Trim().ToUpper(); break; default: //** break; } try { //Eliminar Columnas Actuales(Opcional): GridView1.Columns.Clear(); GridView1.Width = 550; //Objeto Columna: CommandField image; //Crear Columna: image = new CommandField(); image.ButtonType = ButtonType.Image; image.SelectImageUrl = "~/Images/go-search.png"; image.ShowSelectButton = true; image.ItemStyle.Width = 10; image.ItemStyle.Wrap = true; GridView1.Columns.Add(image); BoundField ARTICIDOLD; ARTICIDOLD = new BoundField(); ARTICIDOLD.DataField = "articidold"; ARTICIDOLD.HeaderText = "CODIGO_OLD"; ARTICIDOLD.ItemStyle.Width = 70; GridView1.Columns.Add(ARTICIDOLD); BoundField ARTICNAME; ARTICNAME = new BoundField(); ARTICNAME.DataField = "articname"; ARTICNAME.HeaderText = "ARTICULO"; ARTICNAME.ItemStyle.Width = 250; GridView1.Columns.Add(ARTICNAME); GridView1.DataSource = BL.GetAll(Session["ssEmpresaID"].ToString(), BE); GridView1.DataBind(); GridView1.Visible = true; } catch (Exception ex) { ClientMessage(ex.Message); } }
// ARTICULOS private void data_gridArticulo() { tb_pt_articuloWebBL BL = new tb_pt_articuloWebBL(); tb_pt_articulo BE = new tb_pt_articulo(); DataTable dt = new DataTable(); switch (cmb_articulo.SelectedValue) { case "01": BE.articidold = txt_buscar.Text.Trim().ToUpper(); break; case "02": BE.articname = txt_buscar.Text.Trim().ToUpper(); break; default: //** break; } try { //Eliminar Columnas Actuales(Opcional): dgb_articulo.Columns.Clear(); dgb_articulo.Width = 535; //Objeto Columna: CommandField image; //Crear Columna: image = new CommandField(); image.ButtonType = ButtonType.Image; image.SelectImageUrl = "~/Images/go-search.png"; image.ShowSelectButton = true; image.ItemStyle.Width = 10; image.ItemStyle.Wrap = true; dgb_articulo.Columns.Add(image); BoundField ARTICID; ARTICID = new BoundField(); ARTICID.DataField = "articid"; ARTICID.HeaderText = "CODIGO"; ARTICID.ItemStyle.Width = 50; dgb_articulo.Columns.Add(ARTICID); BoundField ARTICIDOLD; ARTICIDOLD = new BoundField(); ARTICIDOLD.DataField = "articidold"; ARTICIDOLD.HeaderText = "CODIGO"; ARTICIDOLD.ItemStyle.Width = 80; dgb_articulo.Columns.Add(ARTICIDOLD); BoundField ARTICNAME; ARTICNAME = new BoundField(); ARTICNAME.DataField = "articname"; ARTICNAME.HeaderText = "ARTICULO"; ARTICNAME.ItemStyle.Width = 250; dgb_articulo.Columns.Add(ARTICNAME); BE.top = true; //BE.vendorid = txt_vendorid.Value.ToString(); dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0]; if (dt.Rows.Count > 0) { dgb_articulo.DataSource = dt; dgb_articulo.DataBind(); dgb_articulo.Visible = true; } } catch (Exception ex) { throw ex;// ClientMessage(ex.Message); } }
//By Lhy 20110505 ITEM 6 ADD End protected void bindDataSource(DataSet ds) { bool notNullFlag = true; if (ds.Tables[0].Rows.Count == 0) { notNullFlag = false; sql.getNullDataSet(ds); } //By Lhy 20110504 ITEM 6 DEL start //gv_option.Width = Unit.Pixel(450); //By Lhy 20110504 ITEM 6 DEL End gv_option.AutoGenerateColumns = false; gv_option.AllowPaging = false; gv_option.Visible = true; for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString(); //By Lhy 20110504 ITEM 6 DEL start //ds.Tables[0].Columns[i].Caption.ToString(); //By Lhy 20110504 ITEM 6 DEL End //By Lhy 20110504 ITEM 6 ADD start bf.HeaderText = ddlist_description.SelectedItem.Text + " Name"; //By Lhy 20110504 ITEM 6 ADD End bf.ItemStyle.Width = 350; //By Lhy 20110510 ITEM 6 ADD start if (string.Equals(ddlist_description.SelectedValue, "0")) { this.divflow.Attributes.Add("Style", "overflow: auto; height: 480px; width: 221px; position: relative; padding-top: 22px;"); } else if (string.Equals(ddlist_description.SelectedValue, "1")) { this.divflow.Attributes.Add("Style", "overflow: auto; height: 480px; width: 221px; position: relative; padding-top: 22px;"); } else if (string.Equals(ddlist_description.SelectedValue, "2")) { this.divflow.Attributes.Add("Style", "overflow: auto; height: 480px; width: 440px; position: relative; padding-top: 22px;"); } else if (string.Equals(ddlist_description.SelectedValue, "3")) { this.divflow.Attributes.Add("Style", "overflow: auto; height: 480px; width: 320px; position: relative; padding-top: 22px;"); } //By Lhy 20110504 ITEM 10 ADD End bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.Wrap = false; gv_option.Columns.Add(bf); } //By ryzhang 20110516 ITEM 6 ADD Start if (ddlist_description.SelectedIndex != 0 && notNullFlag) { CommandField cf_modifyParent = new CommandField(); cf_modifyParent.ButtonType = ButtonType.Image; cf_modifyParent.ShowSelectButton = true; cf_modifyParent.ShowCancelButton = false; cf_modifyParent.CausesValidation = false; cf_modifyParent.SelectImageUrl = "~/images/edit.jpg"; cf_modifyParent.SelectText = "Modify "+ddlist_description.Items[ddlist_description.SelectedIndex-1].Text; gv_option.Columns.Add(cf_modifyParent); } //By ryzhang 20110516 ITEM 6 ADD End CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv_option.Columns.Add(cf_Delete); gv_option.AllowSorting = true; gv_option.DataSource = ds.Tables[0]; gv_option.DataBind(); gv_option.Columns[gv_option.Columns.Count - 1].Visible = notNullFlag; gv_option.Columns[0].Visible = false; if (getRoleID(getRole()) != "0") gv_option.Columns[gv_option.Columns.Count - 1].Visible = false; }
/// <summary> /// Binding segments or products data to GridView control. /// </summary> /// <param name="ds">Data collection of binding data</param> /// <param name="gv">ID of GridView control</param> /// <param name="flag">if flag is true, data collection is segments, else products</param> protected void bindDataSource(DataSet ds, GridView gv, bool flag) { bool notNullFlag = true; //The flag whether or not dataset is null if (ds.Tables[0].Rows.Count == 0) { notNullFlag = false; sql.getNullDataSet(ds); } //By Wsy 20110512 ITEM 18 DEL Start //gv.Width = Unit.Pixel(800); //By Wsy 20110512 ITEM 18 DEL End //By Wsy 20110512 ITEM 18 ADD Start gv.Width = Unit.Pixel(750); //By Wsy 20110512 ITEM 18 ADD End gv.AutoGenerateColumns = false; gv.AllowPaging = false; gv.Visible = true; for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; if (flag) { if (i == 1) bf.ItemStyle.Width = 100; else bf.ItemStyle.Width = 400; } else { if (i == 1) { bf.ItemStyle.Width = 100; bf.ReadOnly = true; } else bf.ItemStyle.Width = 480; } bf.ControlStyle.Width = bf.ItemStyle.Width; gv.Columns.Add(bf); } if (flag) { CommandField cf_Select = new CommandField(); cf_Select.ButtonType = ButtonType.Image; cf_Select.ShowSelectButton = true; cf_Select.ShowCancelButton = true; cf_Select.SelectImageUrl = "~/images/search.jpg"; cf_Select.SelectText = "Search products that segment consist of"; cf_Select.CausesValidation = false; gv.Columns.Add(cf_Select); } CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit segment"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "Update"; gv.Columns.Add(cf_Update); CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv.Columns.Add(cf_Delete); gv.AllowSorting = true; gv.DataSource = ds.Tables[0]; gv.DataBind(); gv.Columns[gv.Columns.Count - 1].Visible = notNullFlag; gv.Columns[gv.Columns.Count - 2].Visible = notNullFlag; gv.Columns[gv.Columns.Count - 3].Visible = notNullFlag; gv.Columns[0].Visible = false; if (getRoleID(getRole()) != "0") { gv.Columns[gv.Columns.Count - 1].Visible = false; gv.Columns[gv.Columns.Count - 2].Visible = false; } }
/// <summary> /// Bind Grid Data /// </summary> private void BindGrid() { BoundField theCol0 = new BoundField(); theCol0.HeaderText = "Id"; theCol0.DataField = "Id"; theCol0.ItemStyle.CssClass = "textstyle"; grdAllergy.Columns.Add(theCol0); BoundField theCol1 = new BoundField(); theCol1.HeaderText = "Patientid"; theCol1.DataField = "ptn_pk"; theCol1.ItemStyle.CssClass = "textstyle"; grdAllergy.Columns.Add(theCol1); BoundField theCol2 = new BoundField(); theCol2.HeaderText = "AllergyTypeID"; theCol2.DataField = "AllergyTypeID"; theCol2.ItemStyle.CssClass = "textstyle"; grdAllergy.Columns.Add(theCol2); BoundField theCol3 = new BoundField(); theCol3.HeaderText = "Allergy Type"; theCol3.DataField = "AllergyTypeDesc"; theCol3.ItemStyle.CssClass = "textstyle"; theCol3.ReadOnly = true; grdAllergy.Columns.Add(theCol3); BoundField theCol4 = new BoundField(); theCol4.HeaderText = "AllergenTypeID"; theCol4.DataField = "AllergenTypeID"; theCol4.ItemStyle.CssClass = "textstyle"; grdAllergy.Columns.Add(theCol4); BoundField theCol5 = new BoundField(); theCol5.HeaderText = "Allergen"; theCol5.DataField = "AllergenDesc"; theCol5.ItemStyle.CssClass = "textstyle"; theCol5.ReadOnly = true; grdAllergy.Columns.Add(theCol5); BoundField theCol6 = new BoundField(); theCol6.HeaderText = "Other Allergen"; theCol6.ItemStyle.CssClass = "textstyle"; theCol6.DataField = "otherAllergen"; theCol6.ReadOnly = true; grdAllergy.Columns.Add(theCol6); BoundField theCol7 = new BoundField(); theCol7.HeaderText = "Reaction Type"; theCol7.ItemStyle.CssClass = "textstyle"; theCol7.DataField = "typeReaction"; theCol7.ReadOnly = true; grdAllergy.Columns.Add(theCol7); BoundField theCol8 = new BoundField(); // double theCol8.HeaderText = "SevrityTypeID"; theCol8.DataField = "SevrityTypeID"; theCol8.ItemStyle.CssClass = "textstyle"; grdAllergy.Columns.Add(theCol8); BoundField theCol9 = new BoundField(); theCol9.HeaderText = "Severity"; theCol9.ItemStyle.CssClass = "textstyle"; theCol9.DataField = "severityDesc"; theCol9.ReadOnly = true; grdAllergy.Columns.Add(theCol9); BoundField theCol10 = new BoundField(); // double theCol10.HeaderText = "Date Allergy"; theCol10.DataField = "dateAllergy"; theCol10.ItemStyle.CssClass = "textstyle"; theCol10.DataFormatString = "{0:dd-MMM-yyyy}"; grdAllergy.Columns.Add(theCol10); CommandField objfield = new CommandField(); objfield.ButtonType = ButtonType.Link; objfield.DeleteText = "<img src='../Images/del.gif' alt='Delete this' border='0' />"; objfield.ShowDeleteButton = true; grdAllergy.Columns.Add(objfield); grdAllergy.DataBind(); grdAllergy.Columns[0].Visible = false; grdAllergy.Columns[1].Visible = false; grdAllergy.Columns[2].Visible = false; grdAllergy.Columns[4].Visible = false; grdAllergy.Columns[8].Visible = false; }
private void BindGvList() { gvList.Columns.Clear(); string strwhere = "isshow=True and formID=" + dropTable.SelectedValue; DataSet ds=BLL.DataBaseHelper.instance.GetList("FormParas", "*", 0, strwhere, "listpx,id"); string rows=""; if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { //添加自增列 if (chkAutoColumn.Checked) { TemplateField f = new TemplateField(); gvList.Columns.Add(new TemplateField()); } tablename=ds.Tables[0].Rows[0]["tablename"].ToString(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { var row = ds.Tables[0].Rows[i]; rows+=row["columnname"].ToString()+","; BoundField filed = new BoundField(); filed.DataField = row["columnname"].ToString(); filed.HeaderText = row["cname"].ToString(); var listwidth = row["listwidth"].ToString(); int listw=0; int.TryParse(listwidth,out listw); if(listw>0) { filed.ItemStyle.Width = Unit.Pixel(listw); } gvList.Columns.Add(filed); } if(rows.Length>0) rows=rows.Remove(rows.Length-1,1); //string sql = string.Format("select {0} from {1}", rows, tablename); int psize = 0; int.TryParse(txtPageSize.Text.Trim(), out psize); if (psize == 0) gvList.AllowPaging = false; else { gvList.AllowPaging = true; gvList.PageSize = psize; } if(chkEdit.Checked || chkDelete.Checked) { CommandField colfiled = new CommandField(); colfiled.ItemStyle.Width = Unit.Pixel(100); colfiled.ShowEditButton = chkEdit.Checked; colfiled.ShowDeleteButton = chkDelete.Checked; gvList.Columns.Add(colfiled); } gvList.DataSource = BLL.DataBaseHelper.instance.GetList(tablename, rows, 0, "", ""); gvList.DataBind(); //gvList.Columns[0].HeaderText = "我是你的"; //gvList.AutoGenerateColumns = false; } //gvList.DataSource = //gvList.DataBind(); }
private void BindGrid() { BoundField theCol0 = new BoundField(); theCol0.HeaderText = "VisitId"; theCol0.DataField = "VisitId"; theCol0.ItemStyle.CssClass = "textstyle"; GrdPriorART.Columns.Add(theCol0); BoundField theCol1 = new BoundField(); theCol1.HeaderText = "Patientid"; theCol1.DataField = "ptn_pk"; theCol1.ItemStyle.CssClass = "textstyle"; GrdPriorART.Columns.Add(theCol1); BoundField theCol2 = new BoundField(); theCol2.HeaderText = "Facility Name"; theCol2.DataField = "FacilityName"; theCol2.SortExpression = "FacilityName"; theCol2.ReadOnly = true; GrdPriorART.Columns.Add(theCol2); BoundField theCol3 = new BoundField(); theCol3.HeaderText = "Duration of Care From"; theCol3.DataField = "DurationFromDate"; theCol3.DataFormatString = "{0:dd-MMM-yyyy}"; theCol3.SortExpression = "DurationFromDate"; theCol3.ReadOnly = true; GrdPriorART.Columns.Add(theCol3); BoundField theCol8 = new BoundField(); theCol8.HeaderText = "Duration of Care To"; theCol8.DataField = "DurationToDate"; theCol8.DataFormatString = "{0:dd-MMM-yyyy}"; theCol8.SortExpression = "DurationToDate"; theCol8.ReadOnly = true; GrdPriorART.Columns.Add(theCol8); BoundField theCol4 = new BoundField(); theCol4.HeaderText = "Entry type"; theCol4.DataField = "Entrytype"; theCol4.SortExpression = "Entrytype"; theCol4.ReadOnly = true; GrdPriorART.Columns.Add(theCol4); CommandField theCol5 = new CommandField(); theCol5.ButtonType = ButtonType.Link; theCol5.DeleteText = "<img src='../Images/del.gif' alt='Delete this' border='0' />"; theCol5.ShowDeleteButton = true; GrdPriorART.Columns.Add(theCol5); BoundField theCol6 = new BoundField(); theCol6.HeaderText = "FacilityId"; theCol6.DataField = "FacilityId"; GrdPriorART.Columns.Add(theCol6); BoundField theCol7 = new BoundField(); theCol7.HeaderText = "EntryTypeId"; theCol7.DataField = "EntryTypeId"; GrdPriorART.Columns.Add(theCol7); GrdPriorART.Columns[0].Visible = false; GrdPriorART.Columns[1].Visible = false; GrdPriorART.Columns[7].Visible = false; GrdPriorART.Columns[8].Visible = false; }
void LoadGridView() { BoundField ID = new BoundField(); ID.HeaderText = "ID"; ID.DataField = "iID"; BoundField TenTC = new BoundField(); TenTC.HeaderText = "Tên thú cưng"; TenTC.DataField = "sTenThuCung"; BoundField Gia = new BoundField(); Gia.HeaderText = "Giá"; Gia.DataField = "fGia"; BoundField GiongLoai = new BoundField(); GiongLoai.HeaderText = "Giống loài"; GiongLoai.DataField = "sTenLoai"; BoundField CuaHang = new BoundField(); CuaHang.HeaderText = "Cửa hàng"; CuaHang.DataField = "sTenCuaHang"; BoundField GioiTinh = new BoundField(); GioiTinh.HeaderText = "Giới tính"; GioiTinh.DataField = "bGioiTinh"; //BoundField sMoTa = new BoundField(); //ID.HeaderText = "Mô tả"; //ID.DataField = "sMoTa"; ImageField Img = new ImageField(); Img.HeaderText = "Ảnh SP"; Img.DataImageUrlField = "sLinkImg"; Img.DataImageUrlFormatString = "../../img/ThuCung/{0}"; CommandField Sua = new CommandField(); Sua.ButtonType = ButtonType.Button; Sua.SelectText = "Sửa"; Sua.ShowSelectButton = true; grv1.Columns.Add(ID); grv1.Columns.Add(TenTC); grv1.Columns.Add(Gia); grv1.Columns.Add(GiongLoai); grv1.Columns.Add(CuaHang); grv1.Columns.Add(GioiTinh); grv1.Columns.Add(Img); grv1.Columns.Add(Sua); grv1.DataKeyNames = new string[] { "iID" }; grv1.DataSource = kn.ExecuteQuery("GetThuCungAdmin", null, null); grv1.DataBind(); }
public void setBind() { GridView gvshow = new GridView(); //gvshows.Width = Unit.Pixel(700); gvshow.AutoGenerateColumns = false; gvshow.DataSource = dt; gvshow.Font.Size = 12; gvshow.Width = 976; //gvshow.Height = 237; gvshow.CellPadding = 0; gvshow.ForeColor = System.Drawing.ColorTranslator.FromHtml("#333333"); gvshow.GridLines = GridLines.Horizontal; gvshow.ShowHeader = false; gvshow.BorderColor = Color.White; gvshow.BorderWidth = 15; gvshow.EditRowStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#999999"); gvshow.FooterStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#5D7B9D"); gvshow.FooterStyle.ForeColor = Color.White; gvshow.FooterStyle.Font.Bold = true; //gvshow.HeaderStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#568c9e"); //gvshow.HeaderStyle.ForeColor = Color.White; //gvshow.HeaderStyle.Font.Bold = true; gvshow.RowStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#F7F6F3"); gvshow.RowStyle.ForeColor = System.Drawing.ColorTranslator.FromHtml("#333333"); gvshow.SelectedRowStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#E2DED6"); gvshow.SelectedRowStyle.ForeColor = System.Drawing.ColorTranslator.FromHtml("#333333"); gvshow.SelectedRowStyle.Font.Bold = true; // Columns BoundField bc = new BoundField(); bc.DataField = dt.Columns["text"].ColumnName.ToString(); bc.ItemStyle.Width = 700; //bc.HeaderText = dt.Columns[i].Caption.ToString(); //BoundField bc2 = new BoundField(); //bc2.DataField = dt.Columns["id"].ColumnName.ToString(); //gvshow.Columns[1].Visible = false; CommandField cf = new CommandField(); cf.ButtonType = ButtonType.Button; cf.ShowEditButton = true; cf.EditText = "Edit"; cf.UpdateText = "Update"; cf.CancelText = "Cancel"; cf.ControlStyle.CssClass = "gridbutton"; cf.ControlStyle.ForeColor = Color.White; cf.ControlStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#6eb4cd"); cf.CausesValidation = false; cf.ItemStyle.Width = 138; CommandField cf2 = new CommandField(); cf2.ButtonType = ButtonType.Button; cf2.ShowDeleteButton = true; cf2.DeleteText = "Delete"; cf2.ControlStyle.CssClass = "gridbutton"; cf2.ControlStyle.ForeColor = Color.White; cf2.ControlStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#6eb4cd"); cf2.CausesValidation = false; cf2.ItemStyle.Width = 138; gvshow.Columns.Add(bc); gvshow.Columns.Add(cf); gvshow.Columns.Add(cf2); gvshow.RowEditing += new GridViewEditEventHandler(gvshow_RowEditing); // Add edit handler gvshow.RowCancelingEdit += new GridViewCancelEditEventHandler(gvshow_RowCancelingEdit); // Add cancel edit handler gvshow.RowUpdating += new GridViewUpdateEventHandler(gvshow_RowUpdating); // Add update handler gvshow.RowDeleting += new GridViewDeleteEventHandler(gvshow_RowDeleting); // Add delete handler if (!IsPostBack) { // bind(gvshow); gvshow.DataKeyNames = new string[] { "id", "text" };//主键 gvshow.DataBind(); } gvshows.Add(gvshow); }
protected void bindDataByDateByProduct(GridView gv, string bookingY, string deliverY) { bool flag = true; DataSet ds_product = getProductBySegment(getSegmentID()); if (ds_product == null) { gv.Visible = false; return; } DataSet ds = getBookingDataByDateByProduct(ds_product, bookingY, deliverY); if (ds == null) { return; } if (ds.Tables[0].Rows.Count == 0) { flag = false; butFlag = false; sql.getNullDataSet(ds); } else { butFlag = true; } gv.Width = Unit.Pixel(1000); gv.AutoGenerateColumns = false; gv.AllowPaging = false; for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.Wrap = false; bf.ReadOnly = true; if (i > 9) { if (i % 7 == 0) { bf.HeaderText = null; bf.ReadOnly = true; //bf.ControlStyle.Width = 15; //bf.ItemStyle.Width = 15; } else if (i % 7 == 5) { bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; bf.ControlStyle.Width = 50; bf.ItemStyle.Width = 50; bf.ReadOnly = false; } else { bf.ReadOnly = true; } } else { bf.ReadOnly = true; } gv.Columns.Add(bf); } if (butFlag) { CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "OK"; gv.Columns.Add(cf_Update); CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; cf_Delete.CausesValidation = false; gv.Columns.Add(cf_Delete); CommandField cf_Comments = new CommandField(); cf_Comments.ButtonType = ButtonType.Image; cf_Comments.ShowSelectButton = true; cf_Comments.ShowCancelButton = true; cf_Comments.SelectImageUrl = "~/images/comments.jpg"; cf_Comments.SelectText = "Comments"; cf_Comments.CausesValidation = false; gv.Columns.Add(cf_Comments); } if (deliverY == "YTD") { gv.Caption = bookingY + deliverY + " " + fiscalStart + "," + preyear + " to " + meeting.getMonth(month) + meeting.getDay() + "," + year; } else if (bookingY == year.Substring(2, 2).Trim()) { gv.Caption = bookingY + " for " + deliverY + " " + meeting.getMonth(month) + meeting.getDay() + "," + year + " to " + fiscalEnd + "," + bookingY + " for " + deliverY + " delivery"; } else { gv.Caption = bookingY + " for " + deliverY + " " + fiscalStart + "," + year + " to " + fiscalEnd + "," + bookingY + " for " + deliverY + " delivery"; } gv.CaptionAlign = TableCaptionAlign.Top; gv.AllowSorting = true; gv.DataSource = ds.Tables[0]; gv.DataBind(); gv.Columns[0].Visible = false; gv.Columns[1].Visible = false; gv.Columns[2].Visible = false; gv.Columns[3].Visible = false; gv.Columns[9].Visible = false; for (int i = 11; i < gv.Columns.Count - 3; i += 7) { gv.Columns[i].Visible = false; gv.Columns[i + 2].Visible = false; gv.Columns[i + 4].Visible = false; gv.Columns[i + 5].Visible = false; gv.Columns[i + 6].Visible = false; } if (flag) { if (string.Equals(getRoleID(getRole()), "0") || string.Equals(getRoleID(getRole()), "3") || string.Equals(getRoleID(getRole()), "4")) { gv.Columns[gv.Columns.Count - 1].Visible = true; gv.Columns[gv.Columns.Count - 2].Visible = true; gv.Columns[gv.Columns.Count - 3].Visible = true; string str_data = null; string str_comments = null; if (gv.Rows.Count > 0) { for (int i = 0; i < gv.Rows.Count; i++) { for (int j = 11; j < gv.Columns.Count - 3; j += 7) { str_data = gv.Rows[i].Cells[j + 1].Text.Replace(" ", string.Empty); str_comments = gv.Rows[i].Cells[j + 6].Text.Replace(" ", string.Empty); if (!string.Equals(str_data, "0") && str_comments.Length != 0) { gv.Rows[i].Cells[j + 1].ForeColor = Color.Red; gv.Rows[i].Cells[j + 1].ToolTip = str_comments; } } } } } else { gv.Columns[gv.Columns.Count - 1].Visible = false; gv.Columns[gv.Columns.Count - 2].Visible = false; gv.Columns[gv.Columns.Count - 3].Visible = false; } } }
/// <summary> /// GridView-קביעת העמודות ב /// </summary> /// <param name="grd">אליו מוסיפים עמודות GridView-ה</param> /// <param name="columns">אוסף העמודות</param> /// <param name="gridWidth">%-רוחב הגריד ב</param> /// <param name="addCommandColumn">האם להוסיף עמודת עריכה</param> public static void SetColumns(GridView grd, GridViewColumnDefinitions columns, double gridWidth, bool addCommandColumn = false) { BoundField boundColumn; double columnWidth = (gridWidth - EDIT_COLUMN_PERCENT) / columns.Count; grd.AutoGenerateColumns = false; if (addCommandColumn) { CommandField cField = new CommandField(); cField.ButtonType = ButtonType.Image; cField.ItemStyle.Width = new Unit(EDIT_COLUMN_PERCENT, UnitType.Percentage); cField.ControlStyle.Width = new Unit(15, UnitType.Pixel); cField.EditImageUrl = "~/Images/Edit_Icon.png"; cField.EditText = "שינוי"; cField.DeleteImageUrl = "~/Images/Delete_Icon.png"; cField.EditText = "מחיקה"; cField.UpdateImageUrl = "~/Images/OK_Icon.png"; cField.EditText = "עדכון"; cField.CancelImageUrl = "~/Images/Cancel_Icon.png"; cField.EditText = "ביטול"; cField.SelectImageUrl = "~/Images/Select_Icon.png"; cField.EditText = "בחירה"; cField.ShowEditButton = true; cField.ShowDeleteButton = true; //cField.ShowSelectButton = true; grd.Columns.Add(cField); } foreach (GridViewColumnDefinition col in columns) { if (col.ColumnType == ColumnType.PICTURE_COLUMN) { ImageField imageField = new ImageField(); imageField.DataImageUrlField = col.ColumnName; imageField.HeaderText = col.ColumnHeader; imageField.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; imageField.HeaderStyle.VerticalAlign = VerticalAlign.Middle; imageField.DataImageUrlFormatString = @"~\Images\Upload\{0}"; imageField.AlternateText = "תמונה"; imageField.NullDisplayText = "חסרה תמונה"; imageField.ItemStyle.HorizontalAlign = HorizontalAlign.Center; imageField.ItemStyle.VerticalAlign = VerticalAlign.Middle; imageField.ItemStyle.Width = new Unit(columnWidth, UnitType.Percentage);; imageField.ControlStyle.Width = new Unit(col.PictureSize.Width, UnitType.Pixel); imageField.ControlStyle.Height = new Unit(col.PictureSize.Height, UnitType.Pixel); grd.Columns.Add(imageField); } else { boundColumn = new BoundField(); if (col.ColumnType == ColumnType.CHECKBOX_COLUMN) { boundColumn = new CheckBoxField(); } boundColumn.DataField = col.ColumnName; boundColumn.HeaderText = col.ColumnHeader; boundColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; boundColumn.HeaderStyle.VerticalAlign = VerticalAlign.Middle; boundColumn.ItemStyle.Width = new Unit(columnWidth, /* grd.Width.Value / columns.Count, */ UnitType.Percentage); boundColumn.ItemStyle.VerticalAlign = VerticalAlign.Middle; switch (col.ColumnAligment) { case ColumnAligment.CENTER: { boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center; break; } case ColumnAligment.LEFT: { boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left; break; } case ColumnAligment.RIGHT: { boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Right; break; } } grd.Columns.Add(boundColumn); } } }
public static int GetColumnIndex(this GridView gv, string colName) { int ret = -1; int i = 0; i = 0; while (i < gv.Columns.Count) { if (gv.Columns[i].GetType() == typeof(BoundField)) { BoundField bfield = (BoundField)gv.Columns[i]; if (bfield.DataField.ToUpper() == colName.ToUpper()) { break; } } if (gv.Columns[i].GetType() == typeof(CheckBoxField)) { CheckBoxField bfield = (CheckBoxField)gv.Columns[i]; if (bfield.DataField.ToUpper() == colName.ToUpper()) { break; } } if (gv.Columns[i].GetType() == typeof(HyperLinkField)) { HyperLinkField bfield = (HyperLinkField)gv.Columns[i]; if (bfield.SortExpression.ToUpper() == colName.ToUpper()) { break; } } if (gv.Columns[i].GetType() == typeof(ImageField)) { ImageField bfield = (ImageField)gv.Columns[i]; if (bfield.SortExpression.ToUpper() == colName.ToUpper()) { break; } } if (gv.Columns[i].GetType() == typeof(ButtonField)) { ButtonField bfield = (ButtonField)gv.Columns[i]; if (bfield.SortExpression.ToUpper() == colName.ToUpper()) { break; } } if (gv.Columns[i].GetType() == typeof(CommandField)) { CommandField bfield = (CommandField)gv.Columns[i]; if (bfield.SortExpression.ToUpper() == colName.ToUpper()) { break; } } if (gv.Columns[i].GetType() == typeof(TemplateField)) { TemplateField bfield = (TemplateField)gv.Columns[i]; if (bfield.SortExpression.ToUpper() == colName.ToUpper()) { break; } } i++; } if (i < gv.Columns.Count) { ret = i; } return(ret); }
private void bindDataSource(GridView gv, DataSet ds) { bool lastVisible = true; if (ds.Tables[0].Rows.Count == 0) { sql.getNullDataSet(ds); lastVisible = false; } gv.Width = Unit.Pixel(350); gv.AutoGenerateColumns = false; // by dxs 20110511 del start //gv.AllowPaging = true // by dxs 20110511 del end // by dxs 20110513 add start gv.AllowPaging = false; // by dxs 20110513 add end gv.Visible = true; for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; gv.Columns.Add(bf); } CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv.Columns.Add(cf_Delete); gv.AllowSorting = true; gv.DataSource = ds.Tables[0]; gv.DataBind(); gv.Columns[0].Visible = false; gv.Columns[gv.Columns.Count - 1].Visible = lastVisible; if (getRoleID(getRole()) != "0") gv.Columns[gv.Columns.Count - 1].Visible = false; }
public void RecvCommand(Packet pkg) { if (pkg.Dst == id) { CommandField cmd = pkg.Command; CommandField cmd1 = new CommandField(cmd.tag, cmd.operation); if (this.readerType == ReaderType.DROP_COMMAND) return; if (this.readerType == ReaderType.MODIFY_COMMAND) cmd1.operation = -1; // -1表示被修改了 Packet pkg1 = new Packet(this, global.objects[cmd.tag], PacketType.COMMAND); SendPacketDirectly(scheduler.CurrentTime, pkg1); } else RoutePacket(pkg); }
private void RenderDataRow(HtmlTextWriter writer, DataRow row) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); foreach (DataControlField column in Columns) { if (column.Visible) { writer.RenderBeginTag(HtmlTextWriterTag.Td); if (column is BoundField) { writer.Write(row[((BoundField)column).DataField]); } if (column is CommandField) { CommandField cmdField = column as CommandField; if (cmdField.ShowEditButton) { writer.AddAttribute(HtmlTextWriterAttribute.Href, "#"); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(this, "Edit")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.AddAttribute(HtmlTextWriterAttribute.Src, cmdField.EditImageUrl); writer.AddAttribute(HtmlTextWriterAttribute.Alt, cmdField.EditText); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); writer.RenderEndTag(); // A } if (cmdField.ShowDeleteButton) { writer.AddAttribute(HtmlTextWriterAttribute.Href, "#"); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(this, "Delete")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.AddAttribute(HtmlTextWriterAttribute.Src, cmdField.DeleteImageUrl); writer.AddAttribute(HtmlTextWriterAttribute.Alt, cmdField.DeleteText); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); writer.RenderEndTag(); // A } if (cmdField.ShowInsertButton) { writer.AddAttribute(HtmlTextWriterAttribute.Href, "#"); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(this, "Insert")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.AddAttribute(HtmlTextWriterAttribute.Src, cmdField.InsertImageUrl); writer.AddAttribute(HtmlTextWriterAttribute.Alt, cmdField.InsertText); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); writer.RenderEndTag(); // A } if (cmdField.ShowSelectButton) { writer.AddAttribute(HtmlTextWriterAttribute.Href, "#"); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(this, "Select")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.AddAttribute(HtmlTextWriterAttribute.Src, cmdField.SelectImageUrl); writer.AddAttribute(HtmlTextWriterAttribute.Alt, cmdField.SelectText); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); writer.RenderEndTag(); // A } if (cmdField.ShowCancelButton) { writer.AddAttribute(HtmlTextWriterAttribute.Href, "#"); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(this, "Cancel")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.AddAttribute(HtmlTextWriterAttribute.Src, cmdField.CancelImageUrl); writer.AddAttribute(HtmlTextWriterAttribute.Alt, cmdField.CancelText); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); writer.RenderEndTag(); // A } } writer.RenderEndTag(); // Td } } writer.RenderEndTag(); // Tr }
protected void bindDataSource(DataSet ds_market) { bool notNullFlag = true; if (ds_market.Tables[0].Rows.Count == 0) { notNullFlag = false; sql.getNullDataSet(ds_market); } gv_market.Width = Unit.Pixel(800); gv_market.AutoGenerateColumns = false; // by dxs 20110511 del start // gv_market.AllowPaging = true; // by dxs 20110511 del end // by dxs 20110513 add start gv_market.AllowPaging = false; // by dxs 20110513 add end gv_market.Visible = true; // By DingJunjie 20110520 Item 12 Add Start int sumPer = 0; int sumNow = 0; int sumNex = 0; List<string> existList = new List<string>(); if (ds_market != null && ds_market.Tables.Count > 0 && ds_market.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds_market.Tables[0].Rows.Count; i++) { if (!existList.Contains(ds_market.Tables[0].Rows[i][0] + "|" + ds_market.Tables[0].Rows[i][3])) { if (!string.IsNullOrEmpty(ds_market.Tables[0].Rows[i][8].ToString())) { sumPer += int.Parse(ds_market.Tables[0].Rows[i][8].ToString()); } if (!string.IsNullOrEmpty(ds_market.Tables[0].Rows[i][9].ToString())) { sumNow += int.Parse(ds_market.Tables[0].Rows[i][9].ToString()); } if (!string.IsNullOrEmpty(ds_market.Tables[0].Rows[i][10].ToString())) { sumNex += int.Parse(ds_market.Tables[0].Rows[i][10].ToString()); } existList.Add(ds_market.Tables[0].Rows[i][0] + "|" + ds_market.Tables[0].Rows[i][3]); } } } DataRow row = ds_market.Tables[0].NewRow(); row[7] = "Total"; row[8] = sumPer.ToString(); row[9] = sumNow.ToString(); row[10] = sumNex.ToString(); ds_market.Tables[0].Rows.Add(row); // By DingJunjie 20110520 Item 12 Add End for (int i = 0; i < ds_market.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds_market.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds_market.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; bf.ReadOnly = false; // By DingJunjie 20110520 Item 12 Delete Start //if (i == 0 || i == 1 || i == 2 || i == 3) // By DingJunjie 20110520 Item 12 Delete End // By DingJunjie 20110520 Item 12 Add Start if (i == 0 || i == 1 || i == 2 || i == 3 || i == 4 || i == 5 || i == 6 || i == 7) // By DingJunjie 20110520 Item 12 Add End bf.ReadOnly = true; gv_market.Columns.Add(bf); } CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "Update"; gv_market.Columns.Add(cf_Update); CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv_market.Columns.Add(cf_Delete); gv_market.AllowSorting = true; gv_market.DataSource = ds_market.Tables[0]; gv_market.DataBind(); gv_market.Columns[gv_market.Columns.Count - 1].Visible = notNullFlag; gv_market.Columns[gv_market.Columns.Count - 2].Visible = notNullFlag; gv_market.Columns[0].Visible = false; gv_market.Columns[1].Visible = false; // By DingJunjie 20110520 Item 12 Add Start gv_market.Columns[2].Visible = false; gv_market.Columns[3].Visible = false; this.gv_market.Rows[this.gv_market.Rows.Count - 1].Style.Add(HtmlTextWriterStyle.FontWeight, "900"); this.gv_market.Rows[this.gv_market.Rows.Count - 1].Style.Add(HtmlTextWriterStyle.Color, "Red"); this.gv_market.Rows[this.gv_market.Rows.Count - 1].Cells[this.gv_market.Columns.Count - 1].Controls.Clear(); this.gv_market.Rows[this.gv_market.Rows.Count - 1].Cells[this.gv_market.Columns.Count - 2].Controls.Clear(); // By DingJunjie 20110520 Item 12 Add End if (getRoleID(getRole()) != "0") { gv_market.Columns[gv_market.Columns.Count - 1].Visible = false; gv_market.Columns[gv_market.Columns.Count - 2].Visible = false; } lbtn_market.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { /* Session["user"] = (BlUser)new BlShopManager("12345678");*///del BlUser user = (BlUser)Session["user"]; if (!Page.IsPostBack) { //BlOrderUser orderUser=new BlOrderUser(user.Password); // generate grid view dynamically DataTable orders = null; if (user is BlOrderUser blOrderUser) { orders = blOrderUser.GetOrders(true, "");//get orders table } if (orders != null) { DataColumnCollection columns = orders.Columns; foreach (DataColumn column in columns) { if (column.ColumnName != "ID") { //Declare the bound field and allocate memory for the bound field. BoundField field = new BoundField(); //Initialize the DataField value. field.DataField = column.ColumnName; //Initialize the HeaderText field value. field.HeaderText = column.ColumnName; //Add the newly created bound field to the GridView. OrderTable.Columns.Add(field); } } } int type = user.Type; switch (type)//add command fields by user type { case 4: { CommandField cf = new CommandField { ButtonType = ButtonType.Button, DeleteText = "cancel", ShowDeleteButton = true }; OrderTable.Columns.Add(cf); ButtonField b = new ButtonField { Text = "Show order details", ButtonType = ButtonType.Button, CommandName = "ShowOrderDetails" }; OrderTable.Columns.Add(b); break; } case 3: { ButtonField b = new ButtonField { Text = "Start order", ButtonType = ButtonType.Button, CommandName = "updateArrivalTime" }; OrderTable.Columns.Add(b); break; } case 1: { ButtonField b = new ButtonField { Text = "product ready to delivered", ButtonType = ButtonType.Button, CommandName = "updateReadyTime" }; OrderTable.Columns.Add(b); break; } } //BoundField b = new BoundField(); //b.DataField= //if(type==4) //{ // //CommandField cf = new CommandField(); // //cf.ButtonType = ButtonType.Button; // //cf.DeleteText = "c"; // //cf.ShowDeleteButton = true; // //OrderTable.Columns.Add(cf); // OrderTable.Columns[4].AccessibleHeaderText = "c"; //} //set data source Dictionary <string, string> d = new Dictionary <string, string> { { "New orders", "N" }, { "Old orders", "O" } }; NewOrOld.DataSource = d; // Bind the data to the control. NewOrOld.DataTextField = "Key"; NewOrOld.DataValueField = "Value"; NewOrOld.DataBind(); // Set the default selected item, if desired. NewOrOld.SelectedIndex = 0; Dictionary <int, string> status = new Dictionary <int, string> { { 1, "order sent" }, { 2, "shop take care your order" }, { 3, "shipping time selected" }, { 4, "delivery take care your order" }, { 5, "order shipped" }, { -1, "all status" } }; Status.DataSource = status; Status.DataTextField = "Value"; Status.DataValueField = "Key"; Status.SelectedIndex = 6; Status.DataBind(); } int userType = user.Type;//get user type UpOrders(user, ""); }
protected GridView BuildLHAGridView(String user_id, bool new_rep, bool due) { GridView gv = new GridView(); gv.ID = "gv_" + user_id + "_" + new_rep + "_" + due; // Behaviours gv.AllowSorting = true; gv.AutoGenerateColumns = false; gv.AutoGenerateEditButton = false; gv.EnableViewState = false; // Event Handlers gv.RowDataBound += new GridViewRowEventHandler(gv_RowDataBound); gv.Sorting += new GridViewSortEventHandler(gv_Sorting); // Formatting String date_format = "{0:dd/MM/yyyy}"; //{0:MMM dd} // //"{0:dd MMM}" gv.HeaderStyle.BackColor = Util.ColourTryParse("#444444"); gv.HeaderStyle.ForeColor = Color.White; gv.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; gv.HeaderStyle.Font.Size = 8; gv.RowStyle.HorizontalAlign = HorizontalAlign.Center; gv.RowStyle.BackColor = Util.ColourTryParse("#f0f0f0"); gv.RowStyle.CssClass = "gv_hover"; gv.HeaderStyle.CssClass = "gv_h_hover"; gv.CssClass = "BlackGridHead"; gv.BorderWidth = 1; gv.CellPadding = 2; gv.Width = 1280; // 3690; gv.ForeColor = Color.Black; gv.Font.Size = 7; gv.Font.Name = "Verdana"; // Define Columns // 0 CommandField cf = new CommandField(); cf.ShowEditButton = true; cf.ShowDeleteButton = false; cf.ShowCancelButton = true; cf.ItemStyle.BackColor = Color.White; cf.ButtonType = System.Web.UI.WebControls.ButtonType.Image; cf.EditImageUrl = @"~\images\Icons\gridView_Edit.png"; cf.HeaderText = ""; cf.ItemStyle.Width = 18; gv.Columns.Add(cf); // 1 BoundField lha_id = new BoundField(); lha_id.DataField = "LHAID"; gv.Columns.Add(lha_id); // 2 BoundField rep = new BoundField(); rep.HeaderText = "Rep"; rep.DataField = "Rep"; rep.SortExpression = "Rep"; rep.ItemStyle.Width = 70; gv.Columns.Add(rep); // 3 BoundField date_added = new BoundField(); date_added.HeaderText = "Added"; date_added.DataField = "DateAdded"; date_added.SortExpression = "DateAdded"; date_added.DataFormatString = "{0:dd/MM/yy HH:mm}"; date_added.ItemStyle.Width = 90; gv.Columns.Add(date_added); // 4 BoundField month_worked = new BoundField(); month_worked.HeaderText = "Month Worked"; month_worked.DataField = "MonthWorked"; month_worked.SortExpression = "MonthWorked"; month_worked.ItemStyle.Width = 90; gv.Columns.Add(month_worked); // 5 BoundField association = new BoundField(); association.HeaderText = "Association"; association.DataField = "Association"; association.SortExpression = "Association"; association.ItemStyle.Width = 440; gv.Columns.Add(association); // 6 BoundField email = new BoundField(); email.HeaderText = "E-mail"; email.DataField = "Email"; gv.Columns.Add(email); // 7 BoundField tel = new BoundField(); tel.HeaderText = "Tel"; tel.DataField = "Phone"; gv.Columns.Add(tel); // 8 BoundField mobile = new BoundField(); mobile.HeaderText = "Mobile"; mobile.DataField = "Mobile"; gv.Columns.Add(mobile); // 9 BoundField website = new BoundField(); website.HeaderText = "Website"; website.DataField = "Website"; gv.Columns.Add(website); // 10 BoundField mem_list_due_date = new BoundField(); mem_list_due_date.HeaderText = "Due Date"; mem_list_due_date.DataField = "MemListDueDate"; mem_list_due_date.SortExpression = "MemListDueDate"; mem_list_due_date.DataFormatString = date_format; mem_list_due_date.ItemStyle.Width = 72; gv.Columns.Add(mem_list_due_date); // 11 BoundField lh_due_date = new BoundField(); lh_due_date.HeaderText = "LH Due Date"; lh_due_date.DataField = "LetterheadDueDate"; lh_due_date.SortExpression = "LetterheadDueDate"; lh_due_date.DataFormatString = date_format; lh_due_date.ItemStyle.Width = 72; gv.Columns.Add(lh_due_date); // 12 BoundField main_contact_name = new BoundField(); main_contact_name.HeaderText = "Main Contact"; main_contact_name.DataField = "MainContactName"; main_contact_name.SortExpression = "MainContactName"; main_contact_name.ItemStyle.Width = 155; gv.Columns.Add(main_contact_name); // 13 BoundField main_contact_position = new BoundField(); main_contact_position.DataField = "MainContactPosition"; gv.Columns.Add(main_contact_position); // 14 BoundField list_contact_name = new BoundField(); list_contact_name.HeaderText = "List Contact"; list_contact_name.DataField = "ListContactName"; list_contact_name.SortExpression = "ListContactName"; list_contact_name.ItemStyle.Width = 155; gv.Columns.Add(list_contact_name); // 15 BoundField list_contact_position = new BoundField(); list_contact_position.DataField = "ListContactPosition"; gv.Columns.Add(list_contact_position); // 16 BoundField l_level = new BoundField(); l_level.HeaderText = "L"; l_level.DataField = "LLevel"; l_level.SortExpression = "LLevel"; l_level.ItemStyle.Width = 20; gv.Columns.Add(l_level); // 17 BoundField notes = new BoundField(); notes.HeaderText = "N"; notes.DataField = "Notes"; notes.SortExpression = "Notes"; notes.ItemStyle.Width = 20; gv.Columns.Add(notes); // 18 CheckBoxField blown = new CheckBoxField(); blown.DataField = "IsBlown"; blown.HeaderText = "B"; blown.ItemStyle.Width = 15; blown.ControlStyle.BackColor = Color.Red; gv.Columns.Add(blown); // 19 CheckBoxField approved = new CheckBoxField(); approved.DataField = "IsApproved"; approved.HeaderText = "A"; approved.ItemStyle.Width = 15; approved.ControlStyle.BackColor = Color.Lime; gv.Columns.Add(approved); // Due expr String due_expr = "NOT NULL "; if (due) { due_expr = "NULL "; } // Blown / Approved String status_expr = "AND IsBlown=0 AND IsApproved=0"; if (rts.SelectedTab.Text == "Blown") { status_expr = "AND IsBlown=1 AND IsApproved=0"; } else if (rts.SelectedTab.Text == "Approved") { status_expr = "AND IsBlown=0 AND IsApproved=1"; } // Get grid data String qry = "SELECT LHAID, FriendlyName as Rep, DateAdded, MonthWorked, Association, Email, db_lhas.Phone, Mobile, Website, MemListDueDate, LetterheadDueDate, " + "MainContactName, MainContactPosition, ListContactName, ListContactPosition, LLevel, Notes, IsBlown, IsApproved " + "FROM db_lhas, db_userpreferences " + "WHERE db_lhas.UserID = db_userpreferences.UserID " + "AND db_lhas.UserID=@userid AND IsDeleted=0 " + status_expr + " AND MemListDueDate IS " + due_expr; DataTable dt_lhas = SQL.SelectDataTable(qry, "@userid", user_id); dt_lhas.DefaultView.Sort = (String)ViewState["sort_field"] + " " + (String)ViewState["sort_dir"]; // Bind and add to div gv.DataSource = dt_lhas; gv.DataBind(); div_gv.Controls.Add(gv); // Add break label if (new_rep && gv.Rows.Count > 0) { div_gv.Controls.Add(new Label() { Text = "<br/>;" }); } return(gv); }
private void bindDataSource() { bool notNullFlag = true; DataSet ds_currency = getCurrencyInfo(); if (ds_currency.Tables[0].Rows.Count == 0) { notNullFlag = false; sql.getNullDataSet(ds_currency); } gv_currency.Width = Unit.Pixel(400); gv_currency.AutoGenerateColumns = false; // update by SJ 20110510 Start //gv_currency.AllowPaging = true; gv_currency.AllowPaging = false; // update by SJ 20110510 End gv_currency.Visible = true; for (int i = 0; i < ds_currency.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds_currency.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds_currency.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; if (i == 0) bf.ReadOnly = true; else if (i == 1) { bf.ReadOnly = true; bf.ItemStyle.Width = 80; } else if (i == 2) { bf.ReadOnly = false; bf.ItemStyle.Width = 200; } bf.ControlStyle.Width = bf.ItemStyle.Width; gv_currency.Columns.Add(bf); } CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "Update"; gv_currency.Columns.Add(cf_Update); CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv_currency.Columns.Add(cf_Delete); gv_currency.AllowSorting = true; gv_currency.DataSource = ds_currency.Tables[0]; gv_currency.DataBind(); gv_currency.Columns[0].Visible = false; gv_currency.Columns[gv_currency.Columns.Count - 2].Visible = notNullFlag; gv_currency.Columns[gv_currency.Columns.Count - 1].Visible = notNullFlag; if (getRoleID(getRole()) != "0") { gv_currency.Columns[gv_currency.Columns.Count - 2].Visible = false; gv_currency.Columns[gv_currency.Columns.Count - 1].Visible = false; } }
/// <summary> /// /// </summary> /// <param name="e"></param> protected override void OnInit(EventArgs e) { base.OnInit(e); //if (this.Page.IsPostBack) { AssureDataKeys(); if (CreateColumns != null) { CreateColumns(this, EventArgs.Empty); } // добавляем колонки, определенные пользователем, во внутренний грид foreach (DataControlField field in m_columns) { innerGrid.Columns.Add(field); } // устанавливаем видимость заголовка innerGrid.ShowHeader = ShowHeader; // в режима печати настраиваем внешний вид грида if (Page.IsInPrintMode) { ShowPager = false; AllowSelection = false; } // определяем, не находится ли грид в режиме выбора if (IsInSelectMode) { CommandField fld = new CommandField(); fld.ShowSelectButton = true; fld.SelectText = (string)GetLocalResourceObject("SelectButtonCaption"); fld.CausesValidation = false; fld.ItemStyle.Width = Unit.Pixel(60); innerGrid.Columns.Add(fld); // скрываем кнопки добавления и удаления AutoGenerateAddButton = false; AutoGenerateDeleteButton = false; // скрываем колонку выбора AllowSelection = false; } else { if (AutoGenerateDeleteButton && AllowDeleting) // открываем кнопку удаления { plhDeleteButton.Visible = true; // регистрируем скрипт подтверждения удаления //Page.RegisterConfirm(btnDelete_AutoGenerated, Resources.Messages.DeleteConfirmation); // связываем контроллер с гридом gscDelete_AutoGenerated.GridControl = this; } if (AutoGenerateAddButton && AllowAdding) // открываем кнопку добавления { plhAddButton.Visible = true; } if (AutoGenerateEditButton && AllowEditing) // генерируем кнопку редактирования { CommandField fld = new CommandField(); fld.ShowEditButton = true; fld.EditText = (string)GetLocalResourceObject("EditButtonCaption"); fld.CausesValidation = false; fld.ItemStyle.Width = Unit.Pixel(60); innerGrid.Columns.Add(fld); // подписываемся на событие редактирования innerGrid.RowEditing += new GridViewEditEventHandler(OnRowEditing); } if (AllowSelection) { plhTotalCount.Visible = true; } } // подписываемся на событие Select innerGrid.SelectedIndexChanging += new GridViewSelectEventHandler(OnSelectedIndexChanging); // TODO: код из старого грида (надо как-нибудь избавиться) innerGrid.RowEditing += delegate(object s, GridViewEditEventArgs args) { if (RowEdit != null) RowEdit(this, args); }; // инстанцируем под грид шаблон внешних кнопок (но только если это не PrintMode) if (m_ButtonContainerTemplate != null) { m_ButtonContainerTemplate.InstantiateIn(phButtonContainer); } if (ShowPager) { ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(ddlPageSize); //TODO:изменение числа записей на стр /*User.Current.PageSizeChanged += delegate() { RefreshData(true, false); updatePanel.Update(); };*/ this.PageSize = this.PageSize; } } }
private void data_gridArticulo() { //tb_pt_articuloWebBL BL = new tb_pt_articuloWebBL(); //tb_pt_articulo BE = new tb_pt_articulo(); tb_me_stockdiariocabBL BL = new tb_me_stockdiariocabBL(); tb_me_stockdiariocab BE = new tb_me_stockdiariocab(); DataTable dt = new DataTable(); //BE.articidold = txt_articidold.Text.ToUpper(); //BE.top = true; BE.valorfind = txt_filter2.Text; switch (cbo_filtro2.SelectedValue) { case "01": BE.articidold = txt_filter2.Text.Trim().ToUpper(); break; case "02": BE.articname = txt_filter2.Text.Trim().ToUpper(); break; default: //** break; } try { //Eliminar Columnas Actuales(Opcional): GridView2.Columns.Clear(); GridView2.Width = 535; //Objeto Columna: CommandField image; //Crear Columna: image = new CommandField(); image.ButtonType = ButtonType.Image; image.SelectImageUrl = "~/Images/go-search.png"; image.ShowSelectButton = true; image.ItemStyle.Width = 10; image.ItemStyle.Wrap = true; GridView2.Columns.Add(image); BoundField ARTICIDOLD; ARTICIDOLD = new BoundField(); ARTICIDOLD.DataField = "articidold"; ARTICIDOLD.HeaderText = "CODIGO_OLD"; ARTICIDOLD.ItemStyle.Width = 70; GridView2.Columns.Add(ARTICIDOLD); BoundField ARTICNAME; ARTICNAME = new BoundField(); ARTICNAME.DataField = "articname"; ARTICNAME.HeaderText = "ARTICULO"; ARTICNAME.ItemStyle.Width = 250; GridView2.Columns.Add(ARTICNAME); dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0]; GridView2.DataSource = dt; GridView2.DataBind(); GridView2.Visible = true; } catch (Exception ex) { //ClientMessage(ex.Message); Response.Redirect("ErrorPage/Frm_PaginaError_405.aspx"); } }
private void cargarolsGrid() { lblmensagesRols.Visible = false; lblmensagesRols.Text = ""; String[] roles = Roles.GetAllRoles(); ArrayList aTotRols = new ArrayList(); foreach (String rol in roles) { Rol addRol = new Rol(); addRol.NomRol = rol; aTotRols.Add(addRol); } dgvRoles.Columns.Clear(); //Inserir una columna de tipus CommandField per esborrar: CommandField cf = new CommandField(); cf.ButtonType = ButtonType.Image; cf.DeleteImageUrl = "~/Imatges/remove_user_32.png"; cf.ShowDeleteButton = true; cf.ControlStyle.CssClass = "columnasBotonDGV"; dgvRoles.Columns.Add(cf); //Inserir una columna de tipus CommandField per seleccionar: CommandField cfs = new CommandField(); cfs.ButtonType = ButtonType.Image; cfs.SelectImageUrl = "~/Imatges/edit_user_32.png"; cfs.ShowSelectButton = true; cfs.ControlStyle.CssClass = "columnasBotonDGV"; dgvRoles.Columns.Add(cfs); //Inserir una columna de tipus BoundField pel nom d’usuari: BoundField bf = new BoundField(); bf.HeaderText = "Rol"; bf.DataField = "NomRol"; bf.ControlStyle.CssClass = "columnasTextDGV"; dgvRoles.Columns.Add(bf); //Fer que la font de dades de la gridview sigui l’ArrayList i fer que es mostri a la gridview dgvRoles.DataSource = aTotRols; dgvRoles.DataBind(); // Es necesario para bidenar }
private void data_gridRazonSocial() { clienteWebBL BL = new clienteWebBL(); tb_cliente BE = new tb_cliente(); DataTable dt = new DataTable(); switch (cbo_filtro.SelectedValue) { case "01": BE.ctacte = txt_filter.Text.Trim().ToUpper(); break; case "02": BE.ctactename = txt_filter.Text.Trim().ToUpper(); break; default: //** break; } try { //Eliminar Columnas Actuales(Opcional): GridView1.Columns.Clear(); GridView1.Width = 535; //Objeto Columna: CommandField image; //Crear Columna: image = new CommandField(); image.ButtonType = ButtonType.Image; image.SelectImageUrl = "~/Images/go-search.png"; image.ShowSelectButton = true; image.ItemStyle.Width = 10; image.ItemStyle.Wrap = true; GridView1.Columns.Add(image); BoundField DDNNI; DDNNI = new BoundField(); DDNNI.DataField = "ctacte"; DDNNI.HeaderText = "CODIGO"; DDNNI.ItemStyle.Width = 50; GridView1.Columns.Add(DDNNI); BoundField NOMBR; NOMBR = new BoundField(); NOMBR.DataField = "ctactename"; NOMBR.HeaderText = "NOMBRES"; NOMBR.ItemStyle.Width = 250; GridView1.Columns.Add(NOMBR); dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0]; if (dt.Rows.Count > 0) { GridView1.DataSource = dt; GridView1.DataBind(); GridView1.Visible = true; } } catch (Exception ex) { //ClientMessage(ex.Message); Response.Redirect("ErrorPage/Frm_PaginaError_405.aspx"); } }
//private void v_loadGridView() //{ // try // { // Connection connection = new Connection(); // hid_s_tableName.Value = Request.QueryString["tableName"]; // string s_sqlGridView = "select * from " + hid_s_tableName.Value+" order by serial_no"; // connection.connection_DB(s_sqlGridView, 0, false, true, true); // gdv_commonForm.DataSource = connection.ResultsDataSet.Tables[0]; // gdv_commonForm.DataBind(); // } // catch // { // } //} public void v_createBoundField(string data_forB1, string data_forB2, string data_forB3, string data_forB4, string data_forB5, string data_forB6) { List <string> s_labelName = new List <string>(5); s_labelName = (List <string>)ViewState[ViewStateKeys.S_labelName]; List <string> s_visible = new List <string>(4); s_visible = (List <string>)ViewState[ViewStateKeys.S_visible]; BoundField b1 = new BoundField(); b1.HeaderText = data_forB1.ToUpper().Replace("_", " "); b1.DataField = data_forB1; b1.HeaderStyle.CssClass = "hidGridColumn"; b1.ItemStyle.CssClass = "hidGridColumn"; gdv_commonForm.Columns.Add(b1); if (s_visible[0] == "Y") { BoundField b2 = new BoundField(); b2.HeaderText = s_labelName[0]; b2.DataField = data_forB2; gdv_commonForm.Columns.Add(b2); } if (s_visible[1] == "Y") { BoundField b3 = new BoundField(); b3.HeaderText = s_labelName[1]; b3.DataField = data_forB3; gdv_commonForm.Columns.Add(b3); } if (s_visible[2] == "Y") { BoundField b4 = new BoundField(); b4.HeaderText = s_labelName[2]; b4.DataField = data_forB4; gdv_commonForm.Columns.Add(b4); } if (s_visible[3] == "Y") { BoundField b5 = new BoundField(); b5.HeaderText = s_labelName[3]; b5.DataField = data_forB5; gdv_commonForm.Columns.Add(b5); } if (s_visible[4] == "Y") { BoundField b6 = new BoundField(); b6.HeaderText = "Active"; b6.DataField = data_forB6; gdv_commonForm.Columns.Add(b6); } CommandField commandField = new CommandField(); commandField.ShowSelectButton = true; commandField.HeaderStyle.CssClass = "hidGridColumn"; commandField.ItemStyle.CssClass = "hidGridColumn"; gdv_commonForm.Columns.Add(commandField); }
protected void bind(GridView gv, string bookingY, string deliverY, DataSet ds, bool flag) { if (ds != null) { gv.Visible = true; gv.Width = Unit.Pixel(800); gv.AutoGenerateColumns = false; gv.AllowPaging = false; for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString(); bf.ReadOnly = true; bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; if (i % 2 == 1 && i > 4) { bf.HeaderText = null; bf.ReadOnly = true; } if (i % 2 == 0 && i > 3) { bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; bf.ReadOnly = false; bf.ItemStyle.Width = 100; bf.ControlStyle.Width = 100; } gv.Columns.Add(bf); } if (flag) { CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "OK"; gv.Columns.Add(cf_Update); } if (deliverY == "YTD") gv.Caption = bookingY + deliverY + " " + fiscalStart + "," + preyear + " to " + meeting.getMonth(month) + meeting.getDay() + "," + year; else gv.Caption = bookingY + " for " + deliverY + " " + meeting.getMonth(month) + meeting.getDay() + "," + year + " to " + fiscalEnd + "," + bookingY + " for " + deliverY + " delivery"; gv.CaptionAlign = TableCaptionAlign.Top; gv.AllowSorting = true; gv.DataSource = ds.Tables[0]; gv.DataBind(); gv.Columns[0].Visible = false; gv.Columns[1].Visible = false; } else { gv.Visible = false; } }
private void InitializeCustomControls() { this.spgviewAuditControl = new SPGridView(); this.spgviewAuditControl.AutoGenerateColumns = false; this.spgviewAuditControl.Attributes.Add("style", "word-break:keep-all;word-wrap:normal"); string[] ShowTlist = { "交货通知单编号:CommitInCode", "入库单号:CommitInQualifiedNum", "物料名称:MaterialName", "物料编码:MaterialCode", "规格型号:SpecificationModel", "质检合格根/套/件数量:QuantityGentaojian", "质检合格米数量:QuantityMetre", "质检合格吨数量:QuantityTon", "所选单位数量:Quantity", "计量单位:CurUnit", "质检时间:InspectionTime", "检验报告号:InspectionReportNum", "单价:UnitPrice", "金额:Amount", "所属仓库:StorageName", "所属垛位:PileCode", "财务编号:financeCode", "到库时间:StorageTime", "供应商:SupplierName", "物资管理员:MaterialsManager", "仓库员:WarehouseWorker", "备注:Remark" }; string[] HideTlist = { "SupplierIDCol:SupplierID", "MaterialsManagerIDCol:MaterialsManagerID", "WarehouseWorkerIDCol:WarehouseWorkerID", }; BoundField bfColumn; foreach (var kvp in ShowTlist) { bfColumn = new BoundField(); bfColumn.HeaderText = kvp.Split(':')[0]; bfColumn.DataField = kvp.Split(':')[1]; this.spgviewAuditControl.Columns.Add(bfColumn); } //为SPGridView添加状态列 TemplateField tlfAudit = new TemplateField(); tlfAudit.HeaderText = "状态"; tlfAudit.ItemTemplate = new LabelTemplate("状态", DataControlRowType.DataRow); this.spgviewAuditControl.Columns.Add(tlfAudit); CommandField cdf = new CommandField(); cdf.HeaderText = "审核"; cdf.SelectText = "通过/未通过"; cdf.ShowSelectButton = true; this.spgviewAuditControl.SelectedIndexChanging += new GridViewSelectEventHandler(spgviewAuditControl_SelectedIndexChanging); this.spgviewAuditControl.Columns.Add(cdf); //添加隐藏列 foreach (var kvp in HideTlist) { bfColumn = new BoundField(); bfColumn.HeaderText = kvp.Split(':')[0]; bfColumn.DataField = kvp.Split(':')[1]; this.spgviewAuditControl.Columns.Add(bfColumn); } //添加控件到panel1 btnSend = new Button(); btnSend.Text = "生成审核清单"; btnSend.Enabled = false; btnSend.Width = 100; btnSend.Click += new EventHandler(btnSend_Click); btnCancel = new Button(); btnCancel.Text = "返回"; btnCancel.Width = 100; btnCancel.Click += new EventHandler(btnCancel_Click); chbAuditAll = new CheckBox(); chbAuditAll.Checked = false; chbAuditAll.AutoPostBack = true; chbAuditAll.Text = "<font size = 2pt>全部通过审核</font>"; chbAuditAll.CheckedChanged += new EventHandler(chbAuditAll_CheckedChanged); //验证任务是否已经完成 using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { TaskStorageIn tsi = db.TaskStorageIn.SingleOrDefault(u => u.TaskStorageID == Convert.ToInt32(Request.QueryString["TaskStorageID"])); if (tsi.TaskState == "已完成") { this.chbAuditAll.Enabled = false; cdf.Visible = false; } } }
protected void bindComments(GridView gv, string bookingY, string deliverY, DataSet ds, bool flag) { if (ds != null) { gv.Visible = true; gv.Width = Unit.Pixel(800); gv.AutoGenerateColumns = false; gv.AllowPaging = false; for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; if (i == 0) { bf.ReadOnly = true; bf.ItemStyle.Width = 100; bf.ControlStyle.Width = 100; } if (i == 1) { bf.ItemStyle.Width = 600; bf.ControlStyle.Width = 600; } gv.Columns.Add(bf); } if (flag) { CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "OK"; gv.Columns.Add(cf_Update); } gv.AllowSorting = true; gv.DataSource = ds.Tables[0]; gv.DataBind(); } else { gv.Visible = false; } }
protected void bindGVCustomer() { DataSet ds_customer = getEditCustomer(); if (ds_customer == null) return; gv_Customer.Columns.Clear(); bool notNullFlag = true; if (ds_customer.Tables[0].Rows.Count == 0) { notNullFlag = false; sql.getNullDataSet(ds_customer); } gv_Customer.Width = Unit.Pixel(1000); gv_Customer.AutoGenerateColumns = false; gv_Customer.Visible = true; //addCalculateCol(ds_project); //addPODCol(ds_project); for (int i = 0; i < ds_customer.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds_customer.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds_customer.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; bf.ReadOnly = true; //if (i == 6 || i == 7 || i == 9) // bf.ReadOnly = false; if (i < 4) bf.ReadOnly = true; else if (i == 5 || i == 6) bf.ReadOnly = true; else bf.ReadOnly = false; gv_Customer.Columns.Add(bf); } CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "Update"; gv_Customer.Columns.Add(cf_Update); CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv_Customer.Columns.Add(cf_Delete); gv_Customer.AllowSorting = true; gv_Customer.DataSource = ds_customer.Tables[0]; gv_Customer.DataBind(); //gv_Customer.Columns[gv_Customer.Columns.Count - 1].Visible = notNullFlag; //gv_Customer.Columns[gv_Customer.Columns.Count - 2].Visible = notNullFlag; //gv_Customer.Columns[0].Visible = false; //gv_Customer.Columns[1].Visible = false; //if (!string.Equals(getRoleID(getRole()), "0") // && !string.Equals(getRoleID(getRole()), "3") // && !string.Equals(getRoleID(getRole()), "4")) //// By DingJunjie 20110516 Item 7 Add Start //{ // gv_Customer.Columns[gv_Customer.Columns.Count - 2].Visible = false; // gv_Customer.Columns[gv_Customer.Columns.Count - 1].Visible = false; //} gv_Customer.Columns[0].Visible = false; gv_Customer.Columns[1].Visible = false; gv_Customer.Columns[2].Visible = false; gv_Customer.Columns[3].Visible = false; gv_Customer.Visible = true; }
/// <summary> /// Add all columns from a Hansoft project to GridView. /// </summary> private void AddColumns(GridView gView, TabContainer multilineTabs, HPMUniqueID projectID, string project) { CommandField editfield = new CommandField(); editfield.ShowEditButton = true; editfield.ShowDeleteButton = true; editfield.ShowCancelButton = true; editfield.ShowSelectButton = true; editfield.UpdateText = "Save"; gView.Columns.Add(editfield); List<HPMWIColumn> columns = new List<HPMWIColumn>(); HPMProjectCustomColumns customColumns = m_VirtSession.ProjectCustomColumnsGet(projectID); HPMProjectDefaultColumns defaultColumns = m_VirtSession.ProjectGetDefaultActivatedColumns(projectID); HPMProjectDefaultColumns nonHidableDefaultColumns = m_VirtSession.ProjectGetDefaultActivatedNonHidableColumns(projectID, EHPMProjectGetDefaultActivatedNonHidableColumnsFlag.AgileMode | EHPMProjectGetDefaultActivatedNonHidableColumnsFlag.ScheduledMode); foreach (EHPMProjectDefaultColumn defaultColumn in nonHidableDefaultColumns.m_Columns) { HPMColumnDescription description = AddDefaultColumn(gView, multilineTabs, projectID, defaultColumn, project); HPMColumn column = new HPMColumn(); column.m_ColumnType = EHPMColumnType.DefaultColumn; column.m_ColumnID = (uint)defaultColumn; columns.Add(new HPMWIColumn(column, (int)description.m_CriteriaDataType)); } foreach (EHPMProjectDefaultColumn defaultColumn in defaultColumns.m_Columns) { HPMColumnDescription description = AddDefaultColumn(gView, multilineTabs, projectID, defaultColumn, project); HPMColumn column = new HPMColumn(); column.m_ColumnType = EHPMColumnType.DefaultColumn; column.m_ColumnID = (uint)defaultColumn; columns.Add(new HPMWIColumn(column, (int)description.m_CriteriaDataType)); } foreach (HPMProjectCustomColumnsColumn customColumn in customColumns.m_ShowingColumns) { AddCustomColumn(gView, multilineTabs, projectID, customColumn, project); HPMColumn column = new HPMColumn(); column.m_ColumnType = EHPMColumnType.CustomColumn; column.m_ColumnID = customColumn.m_Hash; columns.Add(new HPMWIColumn(column, (int)customColumn.m_Type)); } BoundField idField = new BoundField(); idField.Visible = false; idField.DataField = "_ID"; SetColumns(project, columns); }
/// <summary> /// Bind user information /// </summary> /// <param name="ds">dataset</param> protected void bindDataSource(DataSet ds) { if (ds.Tables[0].Rows.Count == 0) { sql.getNullDataSet(ds); } //gv_administrator.Width = Unit.Pixel(1000); gv_administrator.AutoGenerateColumns = false; //By FXW 20110509 ITEM ADD Start gv_administrator.AllowPaging = false; //By FXW 20110509 ITEM ADD End //By FXW 20110509 ITEM DEL Start //gv_administrator.AllowPaging = true; //By FXW 20110509 ITEM DEL End gv_administrator.Visible = true; //add columns addOperationCol(ds); addCountryCol(ds); addSegmentCol(ds); for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; bf.ReadOnly = false; if (i <= 6 && i != 1 && i != 2 && i != 3 && i != 4 || (i == 10 || i == 12 || i == 11)) { bf.ReadOnly = true; } else if (i == 4) { //By FXW 20110511 ITEM18 DEL Start //bf.ItemStyle.Width = 80; //bf.ItemStyle.Width = 30; //bf.ControlStyle.Width = bf.ItemStyle.Width; //By FXW 20110511 ITEM18 DEL End } else if (i == 7 || i == 8) { //By FXW 20110511 ITEM18 DEL Start //bf.ItemStyle.Width = 100; //bf.ControlStyle.Width = bf.ItemStyle.Width; //By FXW 20110511 ITEM18 DEL End } else { //By FXW 20110511 ITEM18 DEL Start //bf.ItemStyle.Width = 200; //bf.ControlStyle.Width = bf.ItemStyle.Width; //By FXW 20110511 ITEM18 DEL End } gv_administrator.Columns.Add(bf); } CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "Update"; gv_administrator.Columns.Add(cf_Update); CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv_administrator.Columns.Add(cf_Delete); gv_administrator.AllowSorting = true; gv_administrator.DataSource = ds.Tables[0]; gv_administrator.DataBind(); gv_administrator.Columns[0].Visible = false; gv_administrator.Columns[6].Visible = false; gv_administrator.Columns[7].Visible = false; gv_administrator.Columns[8].Visible = false; gv_administrator.Columns[9].Visible = false; if (getRoleID(getRole()) != "0") { gv_administrator.Columns[gv_administrator.Columns.Count - 1].Visible = false; gv_administrator.Columns[gv_administrator.Columns.Count - 2].Visible = false; } }
private void BuildGridView(DataTable dt) { int? nMaxResponseDisplayColumns = null; int n; string strMaxResponseDisplayColumns = System.Configuration.ConfigurationManager.AppSettings["FormBuilder_MaxResponseDisplayColumns"]; if (!string.IsNullOrEmpty(strMaxResponseDisplayColumns)) { if (int.TryParse(strMaxResponseDisplayColumns, out n)) { nMaxResponseDisplayColumns = n; } } grdSubmissions.Columns.Clear(); CommandField command = new CommandField(); command.ShowSelectButton = true; command.SelectText = "Details"; grdSubmissions.Columns.Add(command); int nColumns = 0; foreach (DataColumn column in dt.Columns) { BoundField col = new BoundField(); col.DataField = column.ColumnName; col.HeaderText = GetHeaderText(column.ColumnName); col.SortExpression = column.ColumnName; grdSubmissions.Columns.Add(col); nColumns++; if (nMaxResponseDisplayColumns.HasValue) { if (nColumns >= nMaxResponseDisplayColumns) { break; } } } if ((!nMaxResponseDisplayColumns.HasValue) || (nColumns < nMaxResponseDisplayColumns.Value)) { // add referrer domain and query BoundField refColumn = new BoundField(); refColumn.HeaderText = "Referring Domain"; refColumn.DataField = "ReferringDomain"; grdSubmissions.Columns.Add(refColumn); nColumns++; } if ((!nMaxResponseDisplayColumns.HasValue) || (nColumns < nMaxResponseDisplayColumns.Value)) { BoundField keywordsColumn = new BoundField(); keywordsColumn.HeaderText = "Keywords"; keywordsColumn.DataField = "Keywords"; grdSubmissions.Columns.Add(keywordsColumn); nColumns++; } CommandField delcommand = new CommandField(); delcommand.ShowDeleteButton = true; grdSubmissions.Columns.Add(delcommand); }
private void BindGrid() { BoundField theCol0 = new BoundField(); theCol0.HeaderText = "Id"; theCol0.DataField = "Id"; theCol0.ItemStyle.CssClass = "textstyle"; grdFollowupEducation.Columns.Add(theCol0); BoundField theCol1 = new BoundField(); theCol1.HeaderText = "Patientid"; theCol1.DataField = "Ptn_pk"; theCol1.ItemStyle.CssClass = "textstyle"; grdFollowupEducation.Columns.Add(theCol1); BoundField theCol2 = new BoundField(); theCol2.HeaderText = "Visit Date"; theCol2.DataField = "VisitDate"; theCol2.SortExpression = "VisitDate"; theCol2.ItemStyle.CssClass = "textstyle"; theCol2.ReadOnly = true; grdFollowupEducation.Columns.Add(theCol2); BoundField theCol3 = new BoundField(); theCol3.HeaderText = "Councelling Type"; theCol3.DataField = "CouncellingTypeId"; theCol3.ItemStyle.CssClass = "textstyle"; theCol3.SortExpression = "CouncellingTypeId"; theCol3.ReadOnly = true; grdFollowupEducation.Columns.Add(theCol3); BoundField theCol4 = new BoundField(); theCol4.HeaderText = "Councelling Type"; theCol4.DataField = "CouncellingType"; theCol4.ItemStyle.CssClass = "textstyle"; theCol4.SortExpression = "CouncellingType"; theCol4.ReadOnly = true; grdFollowupEducation.Columns.Add(theCol4); BoundField theCol5 = new BoundField(); theCol5.HeaderText = "Councelling Topic"; theCol5.ItemStyle.CssClass = "textstyle"; theCol5.DataField = "CouncellingTopicId"; theCol5.SortExpression = "CouncellingTopicId"; theCol5.ReadOnly = true; grdFollowupEducation.Columns.Add(theCol5); BoundField theCol6 = new BoundField(); theCol6.HeaderText = "Councelling Topic"; theCol6.ItemStyle.CssClass = "textstyle"; theCol6.DataField = "CouncellingTopic"; theCol6.SortExpression = "CouncellingTopic"; theCol6.ReadOnly = true; grdFollowupEducation.Columns.Add(theCol6); BoundField theCol7 = new BoundField(); theCol7.HeaderText = "Other Councelling Topic"; theCol7.ItemStyle.CssClass = "textstyle"; theCol7.DataField = "OtherDetail"; theCol7.SortExpression = "OtherDetail"; theCol7.ReadOnly = true; grdFollowupEducation.Columns.Add(theCol7); BoundField theCol8 = new BoundField(); theCol8.HeaderText = "Comments"; theCol8.ItemStyle.CssClass = "textstyle"; theCol8.DataField = "Comments"; theCol8.SortExpression = "Comments"; theCol8.ReadOnly = true; grdFollowupEducation.Columns.Add(theCol8); BoundField theCol9 = new BoundField(); theCol9.HeaderText = "Visit_pk"; theCol9.DataField = "Visit_pk"; theCol9.SortExpression = "Visit_pk"; theCol9.ItemStyle.CssClass = "textstyle"; theCol9.ReadOnly = true; grdFollowupEducation.Columns.Add(theCol9); if (Authentication.HasFunctionRight(ApplicationAccess.FollowupEducation, FunctionAccess.Delete, (DataTable)Session["UserRight"]) == true && Session["lblpntstatus"].ToString() != "1") { CommandField objfield = new CommandField(); objfield.ButtonType = ButtonType.Link; objfield.DeleteText = "<img src='../Images/del.gif' alt='Delete' border='0' />"; objfield.ShowDeleteButton = true; grdFollowupEducation.Columns.Add(objfield); } grdFollowupEducation.DataBind(); grdFollowupEducation.Columns[0].Visible = false; grdFollowupEducation.Columns[1].Visible = false; grdFollowupEducation.Columns[3].Visible = false; grdFollowupEducation.Columns[5].Visible = false; grdFollowupEducation.Columns[9].Visible = false; }
private void InitializeCustomControls() { this.spgviewAuditControl = new SPGridView(); this.spgviewAuditControl.AutoGenerateColumns = false; this.spgviewAuditControl.Attributes.Add("style", "word-break:keep-all;word-wrap:normal"); string[] ShowTlist = { "交货通知单编号:CommitInCode", "入库单号:CommitInQualifiedNum", "物料名称:MaterialName", "物料编码:MaterialCode", "规格型号:SpecificationModel", "质检合格根/套/件数量:QuantityGentaojian", "质检合格米数量:QuantityMetre", "质检合格吨数量:QuantityTon", "所选单位数量:Quantity", "计量单位:CurUnit", "单价:UnitPrice", "金额:Amount", "质检时间:InspectionTime", "检验报告号:InspectionReportNum", "所属仓库:StorageName", "所属垛位:PileCode", "财务编号:financeCode", "到库时间:StorageTime", "供应商:SupplierName", "物资管理员:MaterialsManager", "仓库员:WarehouseWorker", "备注:Remark", "状态:AuditStatus", "审核时间:AuditTime", //"CommitInAuditedID:CommitInAuditedID" }; BoundField bfColumn; foreach (var kvp in ShowTlist) { bfColumn = new BoundField(); bfColumn.HeaderText = kvp.Split(':')[0]; bfColumn.DataField = kvp.Split(':')[1]; this.spgviewAuditControl.Columns.Add(bfColumn); } //添加审核列 CommandField cdf = new CommandField(); cdf.HeaderText = "审核"; cdf.SelectText = @"通过/未通过"; cdf.ShowSelectButton = true; this.spgviewAuditControl.SelectedIndexChanging += new GridViewSelectEventHandler(spgviewAuditControl_SelectedIndexChanging); this.spgviewAuditControl.Columns.Add(cdf); bfColumn = new BoundField(); bfColumn.HeaderText = "CommitInAuditedID"; bfColumn.DataField = "CommitInAuditedID"; this.spgviewAuditControl.Columns.Add(bfColumn); //添加控件到panel1 btnModify = new Button(); btnModify.Text = "修改审核清单"; btnModify.Click += new EventHandler(btnModify_Click); btnCancel = new Button(); btnCancel.Text = "返回"; btnCancel.Click += new EventHandler(btnCancel_Click); btnCancel.Width = 100; btnModify.Width = 100; chbAuditAll = new CheckBox(); chbAuditAll.Checked = false; chbAuditAll.AutoPostBack = true; chbAuditAll.Text = "<font size = 2pt>全部通过审核</font>"; chbAuditAll.CheckedChanged += new EventHandler(chbAuditAll_CheckedChanged); }
void BindShippingCalculationTable(bool addInsertRow) { //clear the columns to prevent duplicates ShippingGrid.Columns.Clear(); //We're going to assemble the datasource that we need by putting it together manually here. using (DataTable gridData = new DataTable()) { //We'll need shipping method shipping charge amounts to work with in building the data source using (DataTable methodAmountsData = new DataTable()) { //Populate shipping methods data using (SqlConnection sqlConnection = new SqlConnection(DB.GetDBConn())) { sqlConnection.Open(); string getShippingMethodMapping = "exec aspdnsf_GetStoreShippingMethodMapping @StoreID = @StoreId, @IsRTShipping = 0, @OnlyMapped = @FilterByStore"; var getShippingMethodMappingParams = new[] { new SqlParameter("@StoreId", SelectedStoreId), new SqlParameter("@FilterByStore", FilterShipping), }; using (IDataReader rs = DB.GetRS(getShippingMethodMapping, getShippingMethodMappingParams, sqlConnection)) methodAmountsData.Load(rs); } if (methodAmountsData.Rows.Count == 0) { AlertMessage.PushAlertMessage(String.Format("You do not have any shipping methods setup for the selected store. Please <a href=\"{0}\">click here</a> to set them up.", AppLogic.AdminLinkUrl("shippingmethods.aspx")), AspDotNetStorefrontControls.AlertMessage.AlertType.Error); ShippingRatePanel.Visible = false; return; } using (DataTable shippingRangeData = new DataTable()) { using (SqlConnection sqlConnection = new SqlConnection(DB.GetDBConn())) { //populate the shipping range data var sqlShipping = @"SELECT DISTINCT stp.RowGuid,stp.LowValue,stp.HighValue,stp.MinimumCharge,stp.SurCharge FROM ShippingByTotalByPercent stp with (NOLOCK) INNER JOIN ShippingMethod sm WITH (NOLOCK) ON sm.ShippingMethodid = stp.ShippingMethodId AND (@FilterByStore = 0 or @StoreId = stp.StoreID) order by LowValue" ; var shippingRangeParams = new[] { new SqlParameter("@StoreId", SelectedStoreId), new SqlParameter("@FilterByStore", FilterShipping), }; sqlConnection.Open(); using (IDataReader rs = DB.GetRS(sqlShipping, shippingRangeParams, sqlConnection)) shippingRangeData.Load(rs); } //Add the data columns we'll need on our table and add grid columns to match gridData.Columns.Add(new DataColumn("RowGuid", typeof(string))); gridData.Columns.Add(new DataColumn("LowValue", typeof(string))); BoundField boundField = new BoundField(); boundField.DataField = "LowValue"; boundField.HeaderText = "Low"; boundField.ControlStyle.CssClass = "text-4"; ShippingGrid.Columns.Add(boundField); gridData.Columns.Add(new DataColumn("HighValue", typeof(string))); boundField = new BoundField(); boundField.DataField = "HighValue"; boundField.HeaderText = "High"; boundField.ControlStyle.CssClass = "text-4"; ShippingGrid.Columns.Add(boundField); gridData.Columns.Add(new DataColumn("MinimumCharge", typeof(string))); boundField = new BoundField(); boundField.DataField = "MinimumCharge"; boundField.HeaderText = "Minimum Dollar Amount"; boundField.ControlStyle.CssClass = "text-4"; ShippingGrid.Columns.Add(boundField); gridData.Columns.Add(new DataColumn("SurCharge", typeof(string))); boundField = new BoundField(); boundField.DataField = "SurCharge"; boundField.HeaderText = "Base Dollar Amount"; boundField.ControlStyle.CssClass = "text-4"; ShippingGrid.Columns.Add(boundField); //Add shipping method columns to our grid data foreach (DataRow methodAmountsRow in methodAmountsData.Rows) { var columnName = String.Format("MethodAmount_{0}", DB.RowField(methodAmountsRow, "ShippingMethodID")); gridData.Columns.Add(new DataColumn(columnName, typeof(string))); //add a column to the gridview to hold the data boundField = new BoundField(); boundField.DataField = columnName; boundField.HeaderText = DB.RowFieldByLocale(methodAmountsRow, "Name", LocaleSetting); boundField.ControlStyle.CssClass = "text-4"; ShippingGrid.Columns.Add(boundField); } //now that our columns are setup add rows to our table foreach (DataRow rangeRow in shippingRangeData.Rows) { var newRow = gridData.NewRow(); //add the range data newRow["RowGuid"] = rangeRow["RowGuid"]; newRow["LowValue"] = rangeRow["LowValue"]; newRow["HighValue"] = rangeRow["HighValue"]; newRow["MinimumCharge"] = rangeRow["MinimumCharge"]; newRow["SurCharge"] = rangeRow["SurCharge"]; //add shipping method amounts to our grid data foreach (DataRow methodAmountsRow in methodAmountsData.Rows) { var shippingMethodId = DB.RowFieldInt(methodAmountsRow, "ShippingMethodID"); var shippingRangeGuid = DB.RowFieldGUID(rangeRow, "RowGUID"); Decimal surCharge; // not used here Decimal minimumCharge; // not used here var amount = Shipping.GetShipByTotalByPercentCharge(shippingMethodId, shippingRangeGuid, out minimumCharge, out surCharge); var localizedAmount = Localization.CurrencyStringForDBWithoutExchangeRate(amount); var colName = String.Format("MethodAmount_{0}", shippingMethodId); newRow[colName] = localizedAmount; } gridData.Rows.Add(newRow); } //if we're inserting, add an empty row to the end of the table if (addInsertRow) { var newRow = gridData.NewRow(); //add the range data newRow["RowGuid"] = 0; newRow["LowValue"] = 0; newRow["HighValue"] = 0; newRow["MinimumCharge"] = 0; newRow["SurCharge"] = 0; //add shipping method columns to our insert row foreach (DataRow methodAmountsRow in methodAmountsData.Rows) { var shippingMethodId = DB.RowFieldInt(methodAmountsRow, "ShippingMethodID"); var amount = 0; var localizedAmount = Localization.CurrencyStringForDBWithoutExchangeRate(amount); var colName = String.Format("MethodAmount_{0}", shippingMethodId); newRow[colName] = localizedAmount; } gridData.Rows.Add(newRow); //if we're inserting than we'll want to make the insert row editable ShippingGrid.EditIndex = gridData.Rows.Count - 1; } //add the delete button column ButtonField deleteField = new ButtonField(); deleteField.ButtonType = ButtonType.Link; deleteField.Text = "<i class=\"fa fa-times\"></i> Delete"; deleteField.CommandName = "Delete"; deleteField.ControlStyle.CssClass = "delete-link"; deleteField.ItemStyle.Width = 94; ShippingGrid.Columns.Add(deleteField); //add the edit button column CommandField commandField = new CommandField(); commandField.ButtonType = ButtonType.Link; commandField.ShowEditButton = true; commandField.ShowDeleteButton = false; commandField.ShowCancelButton = true; commandField.ControlStyle.CssClass = "edit-link"; commandField.EditText = "<i class=\"fa fa-share\"></i> Edit"; commandField.CancelText = "<i class=\"fa fa-reply\"></i> Cancel"; commandField.UpdateText = "<i class=\"fa fa-floppy-o\"></i> Save"; commandField.ItemStyle.Width = 84; ShippingGrid.Columns.Add(commandField); ShippingGrid.DataSource = gridData; ShippingGrid.DataBind(); } } } btnInsert.Visible = !addInsertRow; //Hide the 'add new row' button while editing/inserting to avoid confusion and lost data }
private void BindGvList() { gvList.Columns.Clear(); string strwhere = "isshow=True and formID=" + dropTable.SelectedValue; DataSet ds = BLL.DataBaseHelper.instance.GetList("FormParas", "*", 0, strwhere, "listpx,id"); string rows = ""; if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { //添加自增列 if (chkAutoColumn.Checked) { TemplateField f = new TemplateField(); gvList.Columns.Add(new TemplateField()); } tablename = ds.Tables[0].Rows[0]["tablename"].ToString(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { var row = ds.Tables[0].Rows[i]; rows += row["columnname"].ToString() + ","; BoundField filed = new BoundField(); filed.DataField = row["columnname"].ToString(); filed.HeaderText = row["cname"].ToString(); var listwidth = row["listwidth"].ToString(); int listw = 0; int.TryParse(listwidth, out listw); if (listw > 0) { filed.ItemStyle.Width = Unit.Pixel(listw); } gvList.Columns.Add(filed); } if (rows.Length > 0) { rows = rows.Remove(rows.Length - 1, 1); } //string sql = string.Format("select {0} from {1}", rows, tablename); int psize = 0; int.TryParse(txtPageSize.Text.Trim(), out psize); if (psize == 0) { gvList.AllowPaging = false; } else { gvList.AllowPaging = true; gvList.PageSize = psize; } if (chkEdit.Checked || chkDelete.Checked) { CommandField colfiled = new CommandField(); colfiled.ItemStyle.Width = Unit.Pixel(100); colfiled.ShowEditButton = chkEdit.Checked; colfiled.ShowDeleteButton = chkDelete.Checked; gvList.Columns.Add(colfiled); } gvList.DataSource = BLL.DataBaseHelper.instance.GetList(tablename, rows, 0, "", ""); gvList.DataBind(); //gvList.Columns[0].HeaderText = "我是你的"; //gvList.AutoGenerateColumns = false; } //gvList.DataSource = //gvList.DataBind(); }
private void data_gridVendedor() { tb_cxc_vendorBL BL = new tb_cxc_vendorBL(); tb_cxc_vendor BE = new tb_cxc_vendor(); switch (cbo_filtro.SelectedValue) { case "01": BE.vendorid = txt_filter.Text.Trim().ToUpper(); break; case "02": BE.ddnni = txt_filter.Text.Trim().ToUpper(); break; case "03": BE.vendorname = txt_filter.Text.Trim().ToUpper(); break; default: //** break; } try { //Eliminar Columnas Actuales(Opcional): GridView1.Columns.Clear(); GridView1.Width = 550; //Objeto Columna: CommandField image; //Crear Columna: image = new CommandField(); image.ButtonType = ButtonType.Image; image.SelectImageUrl = "~/Images/go-search.png"; image.ShowSelectButton = true; image.ItemStyle.Width = 10; image.ItemStyle.Wrap = true; GridView1.Columns.Add(image); BoundField DDNNI; DDNNI = new BoundField(); DDNNI.DataField = "vendorid"; DDNNI.HeaderText = "CODIGO"; DDNNI.ItemStyle.Width = 80; GridView1.Columns.Add(DDNNI); BoundField APPAT; APPAT = new BoundField(); APPAT.DataField = "ddnni"; APPAT.HeaderText = "DNI"; APPAT.ItemStyle.Width = 80; GridView1.Columns.Add(APPAT); BoundField NOMBR; NOMBR = new BoundField(); NOMBR.DataField = "vendorname"; NOMBR.HeaderText = "NOMBRES"; NOMBR.ItemStyle.Width = 250; GridView1.Columns.Add(NOMBR); GridView1.DataSource = BL.GetAll(Session["ssEmpresaID"].ToString(), BE); GridView1.DataBind(); GridView1.Visible = true; } catch (Exception ex) { ClientMessage(ex.Message); } }
protected void bindDataSourceSaleOrg() { bool flag = true; string str_content = ddlist_find.Text.Trim(); int sel = int.Parse(ddlist_in.SelectedItem.Value.Trim()); DataSet ds_SalesOrg = getSalesOrgInfo(str_content, sel); if (ds_SalesOrg.Tables[0].Rows.Count == 0) { flag = false; sql.getNullDataSet(ds_SalesOrg); } gv_salsOrg.Width = Unit.Pixel(800); gv_salsOrg.AutoGenerateColumns = false; // update by SJ 20110510 Start //gv_salsOrg.AllowPaging = true; gv_salsOrg.AllowPaging = false; // update by SJ 20110510 End gv_salsOrg.Visible = true; for (int i = 0; i < ds_SalesOrg.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds_SalesOrg.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds_SalesOrg.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; bf.ReadOnly = false; if (i == 0 || i == 3) bf.ReadOnly = true; if (i == 1) { bf.ItemStyle.Width = 400; bf.ControlStyle.Width = bf.ItemStyle.Width; } if (i == 2) { bf.ItemStyle.Width = 100; bf.ControlStyle.Width = bf.ItemStyle.Width; } gv_salsOrg.Columns.Add(bf); } CommandField cf_Select = new CommandField(); cf_Select.ButtonType = ButtonType.Image; cf_Select.ShowSelectButton = true; cf_Select.ShowCancelButton = true; cf_Select.SelectImageUrl = "~/images/search.jpg"; cf_Select.SelectText = "Select"; cf_Select.CausesValidation = false; gv_salsOrg.Columns.Add(cf_Select); CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "Update"; gv_salsOrg.Columns.Add(cf_Update); CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv_salsOrg.Columns.Add(cf_Delete); gv_salsOrg.AllowSorting = true; gv_salsOrg.DataSource = ds_SalesOrg.Tables[0]; gv_salsOrg.DataBind(); gv_salsOrg.Columns[0].Visible = false; gv_salsOrg.Columns[gv_salsOrg.Columns.Count - 1].Visible = flag; gv_salsOrg.Columns[gv_salsOrg.Columns.Count - 2].Visible = flag; //By SJ 20110513 Add Strat gv_salsOrg.Columns[gv_salsOrg.Columns.Count - 3].Visible = flag; //By SJ 20110513 Add End if (getRoleID(getRole()) != "0") { gv_salsOrg.Columns[gv_salsOrg.Columns.Count - 1].Visible = false; gv_salsOrg.Columns[gv_salsOrg.Columns.Count - 2].Visible = false; } //By SJ 20110511 DEL Strat //label_RSM_del.Text = ""; //By SJ 20110511 DEL End }
private void cargausersGrid() { ArrayList aTotstUsers = new ArrayList(); //Pilla todos los usarios y hago un bucle donde creo el usuario y lo añado a la arrailist MembershipUserCollection users = Membership.GetAllUsers(); foreach (MembershipUser user in users) { Usuari usu = new Usuari(); usu.NomUsuari = user.UserName; //con el user de "MembershipUser" pudeo conseuir el username y email usu.Email = user.Email; //El profilecoommon es el perfl unico de un user. Se consguigue con un metodo estatido de //profile el GetProfile(Username que he obtenido antees) ProfileCommon perfil = Profile.GetProfile(user.UserName); usu.Cognoms = perfil.Cognoms; usu.Nom = perfil.Nom; aTotstUsers.Add(usu); } //for (int i = dgvUsers.Columns.Count - 1; i >= 0; i--) //{ // dgvUsers.Columns.RemoveAt(i); //} dgvUsers.Columns.Clear(); //Inserir una columna de tipus CommandField per esborrar: CommandField cf = new CommandField(); cf.ButtonType = ButtonType.Image; cf.DeleteImageUrl = "~/Imatges/remove_user_32.png"; cf.ShowDeleteButton = true; cf.ControlStyle.CssClass = "columnasBotonDGV"; dgvUsers.Columns.Add(cf); //Inserir una columna de tipus CommandField per seleccionar: CommandField cfs = new CommandField(); cfs.ButtonType = ButtonType.Image; cfs.SelectImageUrl = "~/Imatges/edit_user_32.png"; cfs.ShowSelectButton = true; cfs.ControlStyle.CssClass = "columnasBotonDGV"; dgvUsers.Columns.Add(cfs); //Inserir una columna de tipus BoundField pel nom d’usuari: BoundField bf = new BoundField(); bf.HeaderText = "Nom usuari"; bf.DataField = "NomUsuari"; bf.ControlStyle.CssClass = "columnasTextDGV"; dgvUsers.Columns.Add(bf); //Inserir una columna de tipus BoundField per l’email: BoundField bfmail = new BoundField(); bfmail.HeaderText = "Correu"; bfmail.DataField = "Email"; bfmail.ControlStyle.CssClass = "columnasTextDGV"; dgvUsers.Columns.Add(bfmail); //Inserir una columna de tipus BoundField pels cognoms: BoundField bfcog = new BoundField(); bfcog.HeaderText = "Cognoms"; bfcog.DataField = "Cognoms"; bfcog.ControlStyle.CssClass = "columnasTextDGV"; dgvUsers.Columns.Add(bfcog); //Inserir una columna de tipus BoundField pel nom: BoundField bfnom = new BoundField(); bfnom.HeaderText = "Nom"; bfnom.DataField = "Nom"; bfnom.ControlStyle.CssClass = "columnasTextDGV"; dgvUsers.Columns.Add(bfnom); //Fer que la font de dades de la gridview sigui l’ArrayList i fer que es mostri a la gridview dgvUsers.DataSource = aTotstUsers; dgvUsers.DataBind(); // Es necesario para bidenar }
protected void bindDataSource(DataSet ds_operation) { bool notNullFlag = true; if (ds_operation.Tables[0].Rows.Count == 0) { notNullFlag = false; sql.getNullDataSet(ds_operation); } //By Wsy 20110512 ITEM 18 DEL Start //gv_Operation.Width = Unit.Pixel(800); //By Wsy 20110512 ITEM 18 DEL End //By Wsy 20110512 ITEM 18 ADD Start gv_Operation.Width = Unit.Pixel(750); //By Wsy 20110512 ITEM 18 ADD End gv_Operation.AutoGenerateColumns = false; //By Wsy 20110512 ITEM 18 DEL Start //gv_Operation.AllowPaging = true; //By Wsy 20110512 ITEM 18 DEL End //By Wsy 20110512 ITEM 18 ADD Start gv_Operation.AllowPaging = false; //By Wsy 20110512 ITEM 18 ADD End gv_Operation.Visible = true; for (int i = 0; i < ds_operation.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds_operation.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds_operation.Tables[0].Columns[i].Caption.ToString(); bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; if (i == 0 || i == 1 || i == 5 || i == 6) { bf.ReadOnly = true; } else if (i == 2) { bf.ItemStyle.Width = 350; bf.ControlStyle.Width = bf.ItemStyle.Width; } else { bf.ItemStyle.Width = 60; bf.ControlStyle.Width = bf.ItemStyle.Width; } gv_Operation.Columns.Add(bf); } CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "Update"; gv_Operation.Columns.Add(cf_Update); CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv_Operation.Columns.Add(cf_Delete); gv_Operation.AllowSorting = true; gv_Operation.DataSource = ds_operation.Tables[0]; gv_Operation.DataBind(); gv_Operation.Columns[gv_Operation.Columns.Count - 1].Visible = notNullFlag; gv_Operation.Columns[gv_Operation.Columns.Count - 2].Visible = notNullFlag; gv_Operation.Columns[0].Visible = false; gv_Operation.Columns[1].Visible = false; if (getRoleID(getRole()) != "0") { gv_Operation.Columns[gv_Operation.Columns.Count - 1].Visible = false; gv_Operation.Columns[gv_Operation.Columns.Count - 2].Visible = false; } lbtn_AddOperation.Visible = true; }
// MARCAS private void data_gridMarca() { tb_pt_marcaBL BL = new tb_pt_marcaBL(); tb_pt_marca BE = new tb_pt_marca(); DataTable dt = new DataTable(); switch (cmb_marca.SelectedValue) { case "01": BE.marcaid = txt_buscar2.Text.Trim().ToUpper(); break; case "02": BE.marcaname = txt_buscar2.Text.Trim().ToUpper(); break; default: //** break; } try { //Eliminar Columnas Actuales(Opcional): dgb_marca.Columns.Clear(); dgb_marca.Width = 535; //Objeto Columna: CommandField image; //Crear Columna: image = new CommandField(); image.ButtonType = ButtonType.Image; image.SelectImageUrl = "~/Images/go-search.png"; image.ShowSelectButton = true; image.ItemStyle.Width = 10; image.ItemStyle.Wrap = true; dgb_marca.Columns.Add(image); BoundField MARCAID; MARCAID = new BoundField(); MARCAID.DataField = "marcaid"; MARCAID.HeaderText = "CODIGO"; MARCAID.ItemStyle.Width = 50; dgb_marca.Columns.Add(MARCAID); BoundField MARCANAME; MARCANAME = new BoundField(); MARCANAME.DataField = "marcaname"; MARCANAME.HeaderText = "MARCA"; MARCANAME.ItemStyle.Width = 250; dgb_marca.Columns.Add(MARCANAME); dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0]; if (dt.Rows.Count > 0) { dgb_marca.DataSource = dt; dgb_marca.DataBind(); dgb_marca.Visible = true; } } catch (Exception ex) { throw ex;// ClientMessage(ex.Message); } }
//With Auto Editing public AutoGridView_withEdit(string db, string sqlcmdtext, string gvname, string controltypes_CSV, string colors_CSV) { DBLookup oDBLookup = new DBLookup(db); DataTable dt; if (sqlcmdtext.StartsWith("sp")) { dt = oDBLookup.GetProc(sqlcmdtext); } else { dt = oDBLookup.GetView(sqlcmdtext); } //columns _columncount = dt.Columns.Count; _colnames = new string[_columncount]; _control_types = new string[_columncount]; _colors = new string[_columncount]; _columncount = dt.Columns.Count; for (int c = 0; c < _columncount; c++) { _colnames[c] = dt.Columns[c].ColumnName; } //get column types if (controltypes_CSV.StartsWith("all_")) { for (int i = 0; i < _columncount; i++) { _control_types[i] = controltypes_CSV.Replace("all_", ""); } } else { _control_types = controltypes_CSV.Split(','); } //get colors if (colors_CSV.StartsWith("all_")) { for (int i = 0; i < _columncount; i++) { _colors[i] = colors_CSV.Replace("all_", ""); } } else { _colors = colors_CSV.Split(','); } //TOFIX: use LINQ to get the columns names //_colnames = (from dc in dt.Columns.Cast<DataColumn>() // select dc.ColumnName).ToArray(); this.ID = gvname; this.EnableViewState = true; this.BorderColor.Equals(System.Drawing.Color.Silver); this.EditRowStyle.BackColor = Color.Yellow; this.AutoGenerateColumns = false; //TRYING TO DO THIS BELOW: //this.AutoGenerateEditButton = AutoGenEditBtn; this.AllowSorting = true; TemplateField tf; #region using AutoGenereateEdit stuff CommandField cf = new CommandField(); cf.ButtonType = ButtonType.Button; cf.ShowCancelButton = true; cf.ShowEditButton = true; //NOT SURE HOW INSERT OPERATES cf.ShowInsertButton = true; cf.CausesValidation = false; this.Columns.Add(cf); #endregion ////Add the Edit/Update buttons //tf = new TemplateField(); //tf.HeaderTemplate = new DynamicGridView_EditUpdateButtons("header", DataControlRowType.Header); //tf.ItemTemplate = new DynamicGridView_EditUpdateButtons("Edit", DataControlRowType.DataRow); //tf.EditItemTemplate = new DynamicGridView_EditUpdateButtons("Update", DataControlRowType.DataRow); //this.Columns.Add(tf); //Loop through the fields for (int i = 0; i < _columncount; i++) { tf = new TemplateField(); #region Create the Control if (i < _control_types.Length) { switch (_control_types[i]) { case "l": tf.HeaderTemplate = new DynamicGridViewTextTemplate(_colnames[i], DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate(_colnames[i], DataControlRowType.DataRow); tf.FooterTemplate = new DynamicGridViewTextBoxTemplate(_colnames[i], DataControlRowType.Footer); tf.EditItemTemplate = new DynamicGridViewTextBoxTemplate(_colnames[i], DataControlRowType.DataRow); break; case "t": tf.HeaderTemplate = new DynamicGridViewTextTemplate(_colnames[i], DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextBoxTemplate(_colnames[i], DataControlRowType.DataRow); tf.FooterTemplate = new DynamicGridViewTextBoxTemplate(_colnames[i], DataControlRowType.Footer); break; case "c": tf.HeaderTemplate = new DynamicGridViewTextTemplate(_colnames[i], DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewCheckBoxTemplate(_colnames[i], DataControlRowType.DataRow); tf.FooterTemplate = new DynamicGridViewCheckBoxTemplate(_colnames[i], DataControlRowType.Footer); break; default: tf.HeaderTemplate = new DynamicGridViewTextTemplate(_colnames[i], DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate(_colnames[i], DataControlRowType.DataRow); tf.FooterTemplate = new DynamicGridViewTextBoxTemplate(_colnames[i], DataControlRowType.Footer); tf.EditItemTemplate = new DynamicGridViewTextBoxTemplate(_colnames[i], DataControlRowType.DataRow); break; } } else //Default to a label if not specified { tf.HeaderTemplate = new DynamicGridViewTextTemplate(_colnames[i], DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate(_colnames[i], DataControlRowType.DataRow); if (_colnames[i] == "created" || _colnames[i] == "createdBy" || _colnames[i] == "updated" || _colnames[i] == "updatedBy") { tf.EditItemTemplate = new DynamicGridViewTextTemplate(_colnames[i], DataControlRowType.DataRow); } else { tf.EditItemTemplate = new DynamicGridViewTextBoxTemplate(_colnames[i], DataControlRowType.DataRow); } tf.FooterTemplate = new DynamicGridViewTextBoxTemplate(_colnames[i], DataControlRowType.Footer); } #endregion #region Format the Control if (i < _colors.Length) { tf.HeaderStyle.CssClass = _colors[i]; tf.ItemStyle.CssClass = _colors[i]; } else //Default to black { tf.HeaderStyle.CssClass = "gvBlack"; tf.ItemStyle.CssClass = "gvBlack"; } #endregion this.Columns.Add(tf); //string[] mydatakeys = datakey.Split(','); //this.DataKeyNames = mydatakeys; } this.DataSource = dt; this.DataBind(); }
private void BindHeader(int formid) { string strwhere = string.Empty; switch (Common.MyWeb.DbType) { case 0: strwhere = "formid=" + formid + " and isshow=True"; break; case 1: strwhere = "formid=" + formid + " and isshow=1";//sqlserver break; case 2: strwhere = "formid=" + formid + " and isshow=1";//sqlite break; } DataSet ds = BLL.DataBaseHelper.instance.GetList("FormPara", "colname,cname", 0, strwhere, ""); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { BoundField bf = new BoundField(); bf.HeaderText = item["cname"].ToString(); bf.DataField = item["colname"].ToString(); bf.SortExpression = item["colname"].ToString(); gvList.Columns.Add(bf); cols += item["colname"].ToString() + ","; } CommandField cf = new CommandField(); cf.HeaderText = "操作"; cf.ShowEditButton = false; cf.ShowDeleteButton = true; cf.ButtonType = ButtonType.Button; gvList.Columns.Add(cf); if (cols.Length > 0) cols = cols.Remove(cols.Length - 1, 1); hidcols.Value = cols; } }
void CargaDatos() { try { acModules.Items.Clear(); List <THE_Catalogo> listCatalogos = MngNegocioCatalogo.ObtieneTodosCatalogos(); grid = new GridView[listCatalogos.Count]; int count = 0; if (listCatalogos.Count > 0) { foreach (THE_Catalogo itemCatalogo in listCatalogos) { List <TDI_OpcionCat> lstOpcioCatalogo = MngNegocioOpcionCat.ObtieneOpcionesPorCatalogo(itemCatalogo.IdCatalogo); if (lstOpcioCatalogo != null) { if (itemCatalogo != null) { RadPanelItem Item = new RadPanelItem(); Item.Text = itemCatalogo.CatalogoDesc; Item.Value = itemCatalogo.IdCatalogo.ToString(); #region Tabla Table tabla = new Table(); tabla.CellSpacing = 10; tabla.CellPadding = 0; tabla.Width = Unit.Percentage(100); TableRow tr = new TableRow(); TableCell celda = new TableCell(); celda.HorizontalAlign = HorizontalAlign.Right; Image btnAgregaNuevo = new Image(); btnAgregaNuevo.ImageUrl = "~/Images/iconoagregar.png"; btnAgregaNuevo.ToolTip = "Agregar Nuevo Resgistro al Catalogo"; btnAgregaNuevo.Width = Unit.Pixel(22); btnAgregaNuevo.Style.Add(HtmlTextWriterStyle.Cursor, "hand"); btnAgregaNuevo.ID = "Agrega" + itemCatalogo.IdCatalogo.ToString(); btnAgregaNuevo.Attributes.Add("onclick", "AgregaNuevo(" + itemCatalogo.IdCatalogo.ToString() + ",'" + itemCatalogo.CatalogoDesc + "');"); celda.Controls.Add(btnAgregaNuevo); Image btnEditar = new Image(); btnEditar.ImageUrl = "~/Images/iconoeditar.png"; btnEditar.ToolTip = "Editar Catalogo"; btnEditar.Width = Unit.Pixel(22); btnEditar.Style.Add(HtmlTextWriterStyle.Cursor, "hand"); btnEditar.ID = "Edita" + itemCatalogo.IdCatalogo.ToString(); btnEditar.Attributes.Add("onclick", "Modifica(" + itemCatalogo.IdCatalogo.ToString() + ",'" + itemCatalogo.CatalogoDesc + "');"); celda.Controls.Add(btnEditar); Image btnEliminar = new Image(); btnEliminar.ImageUrl = "~/Images/iconoeliminar.png"; btnEliminar.ToolTip = "Elimina Catalogo"; btnEliminar.Width = Unit.Pixel(22); btnEliminar.Style.Add(HtmlTextWriterStyle.Cursor, "hand"); btnEliminar.ID = "Elimina" + itemCatalogo.IdCatalogo.ToString(); btnEliminar.Attributes.Add("onclick", "Elimina(" + itemCatalogo.IdCatalogo.ToString() + ",'" + itemCatalogo.CatalogoDesc + "');"); celda.Controls.Add(btnEliminar); tr.Cells.Add(celda); tabla.Rows.Add(tr); #endregion GridView grd = new GridView(); grd.RowEditing += new GridViewEditEventHandler(grd_RowEditing); grd.RowDeleting += new GridViewDeleteEventHandler(grd_RowDeleting); grd.RowDataBound += new GridViewRowEventHandler(grd_RowDataBound); DataTable dataTab = new DataTable(); dataTab.Columns.Add(new DataColumn("IdOpcionCat")); dataTab.Columns.Add(new DataColumn("OpcionCatDesc")); dataTab.Columns.Add(new DataColumn("IdCatalogo")); foreach (TDI_OpcionCat item in lstOpcioCatalogo) { DataRow dr = dataTab.NewRow(); dr[0] = item.IdOpcionCat; dr[1] = item.OpcionCatDesc; dr[2] = itemCatalogo.IdCatalogo.ToString(); dataTab.Rows.Add(dr); dataTab.AcceptChanges(); } if (lstOpcioCatalogo != null) { #region Grid grd.ClientIDMode = System.Web.UI.ClientIDMode.AutoID; grd.Width = Unit.Percentage(100); grd.AutoGenerateColumns = false; grd.ID = "GridVw"; BoundField bound = new BoundField(); bound.DataField = "IdOpcionCat"; bound.HeaderText = "ID"; grd.Columns.Add(bound); BoundField boundOp = new BoundField(); boundOp.DataField = "OpcionCatDesc"; boundOp.HeaderText = "Opción"; grd.Columns.Add(boundOp); CommandField CmdFielEdit = new CommandField(); CmdFielEdit.ButtonType = System.Web.UI.WebControls.ButtonType.Image; CmdFielEdit.EditImageUrl = "~/Images/iconoeditar.png"; CmdFielEdit.HeaderText = ""; CmdFielEdit.ShowEditButton = true; CmdFielEdit.ControlStyle.Width = Unit.Pixel(22); grd.Columns.Add(CmdFielEdit); CommandField CmdFielDelete = new CommandField(); CmdFielDelete.ButtonType = System.Web.UI.WebControls.ButtonType.Image; CmdFielDelete.DeleteImageUrl = "~/Images/iconoeliminar.png"; CmdFielDelete.HeaderText = ""; CmdFielDelete.ShowDeleteButton = true; CmdFielDelete.ControlStyle.Width = Unit.Pixel(22); grd.Columns.Add(CmdFielDelete); BoundField boundCat = new BoundField(); boundCat.DataField = "IdCatalogo"; boundCat.HeaderText = "ID Cat"; grd.Columns.Add(boundCat); grd.Columns[1].ItemStyle.Width = Unit.Percentage(80); grd.Columns[2].ItemStyle.Width = Unit.Percentage(10); grd.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Center; grd.Columns[3].ItemStyle.Width = Unit.Percentage(10); grd.Columns[3].ItemStyle.HorizontalAlign = HorizontalAlign.Center; if (itemCatalogo != null) { grd.DataSource = dataTab; grd.RowStyle.CssClass = "RowsGrid"; grd.HeaderStyle.CssClass = "headerGrid"; grd.EmptyDataText = "<p>Sin opciones enlazadas a este catalogo</p>"; grd.DataBind(); grd.Columns[0].Visible = false; grd.Columns[4].Visible = false; } #endregion } RadPanelItem ItemHijo = new RadPanelItem(); ItemHijo.Controls.Add(tabla); ItemHijo.Controls.Add(grd); Item.Items.Add(ItemHijo); acModules.Items.Add(Item); } } count++; } } } catch (Exception ex) { EncuestasMoviles.Clases.Error.ManejadorErrores(ex, Session["UserName"].ToString(), Session["UserDomain"].ToString(), Session["userMachineName"].ToString(), Session["UserIP"].ToString(), "frmCatalogos", int.Parse(Session["numeroUsuario"].ToString())); } }
protected void bindDataSource() { tbox_date.Text = ddlist_meetingdate.SelectedItem.Text.Trim(); DataSet ds_currency = getCurrencyInfo(ddlist_meetingdate.SelectedItem.Value.Trim()); if (ds_currency != null) { gv_currency.Width = Unit.Pixel(600); gv_currency.AutoGenerateColumns = false; // update by SJ 20110511 Start //gv_currency.AllowPaging = true; gv_currency.AllowPaging = false; // update by SJ 20110511 End gv_currency.Visible = true; for (int i = 0; i < ds_currency.Tables[0].Columns.Count; i++) { BoundField bf = new BoundField(); bf.DataField = ds_currency.Tables[0].Columns[i].ColumnName.ToString(); bf.HeaderText = ds_currency.Tables[0].Columns[i].Caption.ToString(); if (ds_currency.Tables[0].Columns[i].ColumnName == "ID" || ds_currency.Tables[0].Columns[i].ColumnName == "Currency") bf.ReadOnly = true; else { bf.ItemStyle.Width = 120; bf.ReadOnly = false; } bf.ControlStyle.Width = bf.ItemStyle.Width; bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; gv_currency.Columns.Add(bf); } CommandField cf_Update = new CommandField(); cf_Update.ButtonType = ButtonType.Image; cf_Update.ShowEditButton = true; cf_Update.ShowCancelButton = true; cf_Update.EditImageUrl = "~/images/edit.jpg"; cf_Update.EditText = "Edit"; cf_Update.CausesValidation = false; cf_Update.CancelImageUrl = "~/images/cancel.jpg"; cf_Update.CancelText = "Cancel"; cf_Update.UpdateImageUrl = "~/images/ok.jpg"; cf_Update.UpdateText = "Update"; gv_currency.Columns.Add(cf_Update); CommandField cf_Delete = new CommandField(); cf_Delete.ButtonType = ButtonType.Image; cf_Delete.ShowDeleteButton = true; cf_Delete.ShowCancelButton = true; cf_Delete.CausesValidation = false; cf_Delete.DeleteImageUrl = "~/images/del.jpg"; cf_Delete.DeleteText = "Delete"; gv_currency.Columns.Add(cf_Delete); gv_currency.AllowSorting = true; gv_currency.DataSource = ds_currency.Tables[0]; gv_currency.DataBind(); gv_currency.Columns[0].Visible = false; if (getRoleID(getRole()) != "0") { gv_currency.Columns[gv_currency.Columns.Count - 1].Visible = false; gv_currency.Columns[gv_currency.Columns.Count - 2].Visible = false; } } }
void RefreshGridView() { GlobalMethods.DeleteOldFile(); GridView1.RowDeleting += new GridViewDeleteEventHandler(GridView1_RowDeleting); GridView1.RowEditing += new GridViewEditEventHandler(GridView1_RowEditing); GridView1.SelectedIndexChanged += new EventHandler(GridView1_SelectedIndexChanged); string[] files = System.IO.Directory.GetFiles(Server.MapPath("~/dumpfiles")); DataTable dt = new DataTable(); dt.Columns.Add("Filename"); foreach (string s in files) { if (!s.EndsWith("sql")) { continue; } dt.Rows.Add(System.IO.Path.GetFileName(s)); } if (Session["filedeleted"] != null) { Label1.Text = Session["filedeleted"] + " is deleted.<br />"; Session["filedeleted"] = null; } else { Label1.Text = string.Empty; } if (dt.Rows.Count == 0) { Label1.Text += "No files."; } else { Label1.Text += string.Empty; } GridView1.DataSource = null; GridView1.DataBind(); GridView1.Columns.Clear(); GridView1.DataSource = dt; GridView1.AutoGenerateColumns = false; BoundField colnName = new BoundField(); colnName.HeaderText = "Filename"; colnName.DataField = "Filename"; colnName.ReadOnly = true; CommandField colnDel = new CommandField(); colnDel.DeleteText = "Delete"; colnDel.ShowDeleteButton = true; CommandField colnDownload = new CommandField(); colnDownload.EditText = "Download"; colnDownload.ShowEditButton = true; CommandField colnView = new CommandField(); colnView.ShowSelectButton = true; colnView.SelectText = "View"; GridView1.Columns.Add(colnName); GridView1.Columns.Add(colnDel); GridView1.Columns.Add(colnDownload); GridView1.Columns.Add(colnView); GridView1.Columns[0].ItemStyle.Width = Unit.Pixel(150); GridView1.Columns[1].ItemStyle.Width = Unit.Pixel(55); GridView1.Columns[2].ItemStyle.Width = Unit.Pixel(70); GridView1.Columns[3].ItemStyle.Width = Unit.Pixel(70); GridView1.SelectedIndex = -1; GridView1.DataBind(); Session.Clear(); }