//gridViewUI��ʾ private void GridView1BrowseUI(BrowseEditMode Mode) { //ѡҪ��sysTable���������Щ�ֶ�Ҫ��ʾ���� if (ViewState["sysPEEBITableColumn"] == null) { return; } DataTable dt = (DataTable)ViewState["sysPEEBITableColumn"]; if (ViewState["sysPEEBITableColumnTEMP"] == null) { return; } DataTable dt2 = (DataTable)ViewState["sysPEEBITableColumnTEMP"]; if (ViewState["sysPEEBITableColumnTEMPAdd"] == null) { return; } DataTable dt3 = (DataTable)ViewState["sysPEEBITableColumnTEMPAdd"]; int iCount = 1; for (int i = 0; i < 3; i++) { DataTable dtCopy = new DataTable(); switch (i) { case 0: dtCopy = dt.Copy(); break; case 1: dtCopy = dt2.Copy(); iCount = 0; break; case 2: dtCopy = dt3.Copy(); iCount = 0; break; } if (dtCopy != null) { if (dtCopy.Rows.Count > 0) { int gvWidth = 25; if (iCount == 1) { ButtonField btnSel = new ButtonField(); btnSel.Text = "��ϸ"; btnSel.CommandName = "select"; btnSel.ShowHeader = true; btnSel.HeaderText = "��ϸ"; btnSel.ButtonType = ButtonType.Button; btnSel.ItemStyle.Width = 25; GridView1.Columns.Add(btnSel); iCount = 0; } foreach (DataRow dr in dtCopy.Select("")) { if (dr["ColIsShow"] != null) { if (dr["ColIsShow"].ToString() == "1") { if (Mode == BrowseEditMode.Browse) { switch (dr["ColType"].ToString()) { case "CheckBox": VBControls.VBProject.WebControls.TBCheckBoxField mCheckBoxField = new VBControls.VBProject.WebControls.TBCheckBoxField(); switch (WebUtils.GetCookie("Language")) { case "zh-CN": mCheckBoxField.HeaderText = dr["ColDescriptionCN"].ToString(); break; case "en-US": mCheckBoxField.HeaderText = dr["ColDescriptionUS"].ToString(); break; case "zh-TW": mCheckBoxField.HeaderText = dr["ColDescriptionTW"].ToString(); break; default: mCheckBoxField.HeaderText = dr["ColDescriptionCN"].ToString(); break; } mCheckBoxField.DataField = dr["ColName"].ToString(); mCheckBoxField.DefineValue = "1/0"; mCheckBoxField.ItemStyle.Width = (dr["ColWidth"] == null) ? 50 : Convert.ToInt32(dr["ColWidth"].ToString()); GridView1.Columns.Add(mCheckBoxField); break; default: BoundField mBoundField = new BoundField(); switch (WebUtils.GetCookie("Language")) { case "zh-CN": mBoundField.HeaderText = dr["ColDescriptionCN"].ToString(); break; case "en-US": mBoundField.HeaderText = dr["ColDescriptionUS"].ToString(); break; case "zh-TW": mBoundField.HeaderText = dr["ColDescriptionTW"].ToString(); break; default: mBoundField.HeaderText = dr["ColDescriptionCN"].ToString(); break; } if (dr["TypeName"].ToString() == "smalldatetime" || dr["TypeName"].ToString() == "datetime") { mBoundField.HtmlEncode = false; mBoundField.DataFormatString = "{0:d}"; } mBoundField.DataField = dr["ColName"].ToString(); mBoundField.ItemStyle.Width = dr["ColWidth"] == null ? 100 : Convert.ToInt32(dr["ColWidth"].ToString()); gvWidth += Convert.ToInt16(mBoundField.ItemStyle.Width.Value); GridView1.Columns.Add(mBoundField); break; } } } } } if (gvWidth > 650) { GridView1.Width = gvWidth; } else { GridView1.Width = Unit.Percentage(100); } } else { GridView1.Width = Unit.Percentage(100); } } else { GridView1.Width = Unit.Percentage(100); } } }
private void GridView1BrowseUI(BrowseEditMode Mode) { string[] ColumnName = { "ColName", "ColType", "ColDescriptionCN" }; string[] ColText = { "字段名", "字段类型", "字段说明" }; int [] ColWidth ={50,50,100}; ButtonField btnSel = new ButtonField(); btnSel.Text = "删除"; btnSel.CommandName = "Del"; btnSel.ShowHeader = true; btnSel.HeaderText = "操作"; btnSel.ButtonType = ButtonType.Button; btnSel.ItemStyle.Width = 5; GridView1.Columns.Add(btnSel); for (int i = 0; i < ColumnName.Length; i++) { BoundField mBoundField = new BoundField(); mBoundField.HeaderText = ColText[i]; mBoundField.DataField = ColumnName[i]; mBoundField.ItemStyle.Width = ColWidth[i]; GridView1.Columns.Add(mBoundField); } }
//gridViewUI��ʾ private void GridView1BrowseUI(BrowseEditMode Mode) { //ѡҪ��sysTable���������Щ�ֶ�Ҫ��ʾ���� if (ViewState["sysTableColumn"] == null) { return; } DataTable dt = (DataTable)ViewState["sysTableColumn"]; if (dt != null) { if (dt.Rows.Count > 0) { ButtonField btnSel = new ButtonField(); btnSel.Text = "Select"; btnSel.CommandName = "select"; btnSel.ShowHeader = true; btnSel.HeaderText = "Select"; btnSel.ButtonType = ButtonType.Button; btnSel.ItemStyle.Width = 30; GridView1.Columns.Add(btnSel); foreach (DataRow dr in dt.Select("")) { if (dr["ColIsShow"] != null) { if (dr["ColIsShow"].ToString() == "1") { if (Mode == BrowseEditMode.Browse) { switch (dr["ColType"].ToString()) { case "CheckBox": VBControls.VBProject.WebControls.TBCheckBoxField mCheckBoxField = new VBControls.VBProject.WebControls.TBCheckBoxField(); switch (WebUtils.GetCookie("Language")) { case "zh-CN": mCheckBoxField.HeaderText = dr["ColDescriptionCN"].ToString(); break; case "en-US": mCheckBoxField.HeaderText = dr["ColDescriptionUS"].ToString(); break; case "zh-TW": mCheckBoxField.HeaderText = dr["ColDescriptionTW"].ToString(); break; default: mCheckBoxField.HeaderText = dr["ColDescriptionCN"].ToString(); break; } mCheckBoxField.DataField = dr["ColName"].ToString(); mCheckBoxField.DefineValue = "1/0"; mCheckBoxField.ItemStyle.Width = (dr["ColWidth"] == null) ? 50 : Convert.ToInt32(dr["ColWidth"].ToString()); GridView1.Columns.Add(mCheckBoxField); break; default: BoundField mBoundField = new BoundField(); switch (WebUtils.GetCookie("Language")) { case "zh-CN": mBoundField.HeaderText = dr["ColDescriptionCN"].ToString(); break; case "en-US": mBoundField.HeaderText = dr["ColDescriptionUS"].ToString(); break; case "zh-TW": mBoundField.HeaderText = dr["ColDescriptionTW"].ToString(); break; default: mBoundField.HeaderText = dr["ColDescriptionCN"].ToString(); break; } mBoundField.DataField = dr["ColName"].ToString(); mBoundField.ItemStyle.Width = dr["ColWidth"] == null ? 100 : Convert.ToInt32(dr["ColWidth"].ToString()); GridView1.Columns.Add(mBoundField); break; } } } } } } } }