protected void lnkGrpPermDelete_OnClick(object sender, EventArgs e) { LinkButton lnkDelete = (LinkButton)sender; if (ViewState["dtGroupsPermissions"] != null) { dtGroupsPermissions = (DataTable)ViewState["dtGroupsPermissions"]; foreach (DataRow dr in dtGroupsPermissions.Rows) { if ((dr["GroupsID"] + ";" + dr["PermissionsID"]) == lnkDelete.CommandArgument) { dtGroupsPermissions.Rows.Remove(dr); break; } } GvGroupsPermissions.DataSource = dtGroupsPermissions; GvGroupsPermissions.DataBind(); ViewState["dtGroupsPermissions"] = dtGroupsPermissions; Button1.Focus(); } }
void spgvMaterial_PageIndexChanging(object sender, GridViewPageEventArgs e) { SPGridView spgv = sender as SPGridView; spgv.PageIndex = e.NewPageIndex; spgv.DataBind(); }
private void BindDataToCustomControls() { using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { //初始化表头 SrinRepairPlan srp = db.SrinRepairPlan.SingleOrDefault(u => u.SrinRepairPlanID == _formid); ((Label)GetControltByMaster("lblMaterial")).Text = srp.EmpInfo.EmpName; ((Label)GetControltByMaster("lblDate")).Text = string.Concat(srp.CreateTime.ToLongDateString(), srp.CreateTime.ToLongTimeString()); ((Label)GetControltByMaster("lblCode")).Text = srp.SrinRepairPlanCode; spgvMaterial.DataSource = from a in db.SrinMaterialRepairDetails where a.SrinRepairPlanID == _formid select new { a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.MaterialInfo.MaterialName, a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.MaterialInfo.SpecificationModel, a.Manufacturer.ManufacturerName, a.ArrivalTime, a.Gentaojian, a.RepairReason, a.PlanTime, a.RealGentaojian, a.RealTime, a.Remark, a.SrinMaterialRepairDetailsID }; spgvMaterial.DataBind(); } }
private void ListFields() { DataTable dt = new DataTable(); dt.Columns.Add("DisplayName"); dt.Columns.Add("FieldType"); dt.Columns.Add("InternalName"); int cntFields = 0; foreach (SPField fld in this.CurrentList.Fields) { if (!fld.Sealed && (!fld.ReadOnlyField || fld.Type == SPFieldType.Calculated) && fld.Type != SPFieldType.Attachments && fld.InternalName != "Order" && fld.Type != SPFieldType.File && fld.InternalName != "MetaInfo") { dt.Rows.Add(new string[] { fld.Title, fld.TypeShortDescription, fld.InternalName }); } cntFields++; } dt.DefaultView.Sort = "DisplayName ASC"; //if (cntFields > 0) GvFields.PageSize = cntFields; GvFields.DataSource = dt; GvFields.DataBind(); }
protected override void CreateChildControls() { base.CreateChildControls(); SPWeb web = SPContext.Current.Web; var lists = web.Lists.Cast <SPList>(); webLists = new SPGridView(); webLists.AutoGenerateColumns = false; webLists.DataSource = lists; webLists.Columns.Add(new BoundField() { DataField = "Title", HeaderText = "List Name" }); webLists.Columns.Add(new BoundField() { DataField = "ItemCount", HeaderText = "No Items" }); webLists.Columns.Add(new CommandField() { HeaderText = "Action", ControlStyle = { Width = new Unit(70) }, SelectText = "Show Items", ShowSelectButton = true }); webLists.DataKeyNames = new string[] { "Title" }; webLists.DataBind(); Controls.Add(webLists); webLists.SelectedIndexChanged += new EventHandler(webLists_SelectedIndexChanged); }
protected void InitGridView() { try { currentStorageManager = StorageManager.Lookup(WebAppSelector.CurrentItem); // Pas la peine de stocker le storageManager dans le ViewState, il y a déjà une gestion de la mise en cache du côté StorageManager. ChkBoxLoggerEnabled.Checked = true; // Si le lookup ne génère pas d'exception c'est que le logger est activé pour la web application if (currentStorageManager.StorageProviders.Count > 0) { GridViewProviders.DataSource = currentStorageManager.StorageProviders; GridViewProviders.DataBind(); } else { LabelErrorMessage.Text = (string)GetGlobalResourceObject("AlphaMosaikLogger", "ConfigurePage_NoProviderAvailable"); } } catch (LoggerConfigurationException ex) { LabelErrorMessage.Text = ex.Message; } catch (LoggerNotEnabledException) { LabelErrorMessage.Text = "The logger is not enabled on this web application."; // TODO : resx ChkBoxLoggerEnabled.Checked = false; } }
private void ListFields() { DataTable dt = new DataTable(); dt.Columns.Add("DisplayName"); dt.Columns.Add("InternalName"); dt.Columns.Add("Synch"); dt.Columns.Add("Seal"); int cntFields = 0; foreach (SPField fld in this.CurrentList.Fields) { if (!fld.Sealed && fld.Type != SPFieldType.Attachments && fld.InternalName != "Order" && fld.Type != SPFieldType.File && fld.InternalName != "MetaInfo" && (!fld.ReadOnlyField || fld.Type == SPFieldType.Calculated)) { dt.Rows.Add(new string[] { fld.Title, fld.InternalName, "True", "False" }); } cntFields++; } lblResult.Height = cntFields * 16; GvFields.PageSize = cntFields; GvFields.DataSource = dt; GvFields.DataBind(); }
private void ListUsers() { ArrayList users = CoreFunctions.getFeatureUsers(int.Parse(Request["feature"])); DataTable dt = new DataTable(); dt.Columns.Add("username"); dt.Columns.Add("encusername"); int cntUsers = 0; foreach (string username in users) { if (username != "") { cntUsers++; dt.Rows.Add(new string[] { username, System.Web.HttpUtility.UrlEncode(username) }); } } GvItems.DataSource = dt; GvItems.DataBind(); lblUsage.Text = cntUsers.ToString(); lblMaxUsers.Text = CoreFunctions.getFeatureLicenseUserCount(int.Parse(Request["feature"])); }
/// <summary> /// Binds this query to an SPGridView control. /// </summary> /// <param name="web"></param> /// <param name="gridView"></param> /// <param name="query"></param> /// <param name="initColumns"></param> private void BindToGridView(SPWeb web, SPGridView gridView, SPSiteDataQuery query, bool initColumns) { // Execute the query. DataTable table = web.GetSiteData(query); // Initialize the gridview columns, if requested if (initColumns) { gridView.AutoGenerateColumns = false; gridView.Columns.Clear(); foreach (var col in table.Columns.Cast <DataColumn>() .Where(IsBindableColumn) .Select(column => new BoundField { DataField = column.ColumnName, HeaderText = string.IsNullOrEmpty(column.Caption) ? column.ColumnName : column.Caption })) { gridView.Columns.Add(col); } } // Bind the data to the view. gridView.DataSource = table; gridView.DataBind(); }
protected void LoadSnapshots() { try { DataTable manipulateDt = new DataTable(); _DAO.Command = "spGetSnapshotManagementDetails"; _DAO.CommandType = CommandType.StoredProcedure; DataTable dt = _DAO.GetTable(_DAO.GetClientReportingConnection); SPBoundField gridColumn; if (!IsPostBack) { foreach (DataColumn column in dt.Columns) { gridColumn = new SPBoundField(); gridColumn.HeaderText = column.ColumnName; gridColumn.DataField = column.ColumnName; if (column.ColumnName.ToLower().EndsWith("id")) { gridColumn.Visible = false; } grdVwSnapshots.Columns.Add(gridColumn); } grdVwSnapshots.DataSource = dt; grdVwSnapshots.DataBind(); } } catch { } }
protected override void CreateChildControls() { var claimsUser = Page.User as IClaimsPrincipal; if (claimsUser != null) { DataRow dr; DataTable claimsTable = new DataTable(); claimsTable.Columns.Add("Type", typeof(string)); claimsTable.Columns.Add("Value", typeof(string)); IClaimsIdentity ci = (IClaimsIdentity)claimsUser.Identity; foreach (Claim c in ci.Claims) { dr = claimsTable.NewRow(); dr["Type"] = c.ClaimType.ToString(); dr["Value"] = c.Value.ToString(); claimsTable.Rows.Add(dr); } // Standard SPGridView to display our claims table SPGridView claimsGrid = new SPGridView(); // This eventhandler is used to add the word-break style //claimsGrid.RowDataBound += new GridViewRowEventHandler(claimsGrid_RowDataBound); // AutoGenerate must be false for SPGridView claimsGrid.AutoGenerateColumns = false; claimsGrid.DataSource = claimsTable; SPBoundField boundField; boundField = new SPBoundField(); boundField.HeaderText = "Type"; boundField.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; boundField.DataField = "Type"; claimsGrid.Columns.Add(boundField); boundField = new SPBoundField(); boundField.HeaderText = "Value"; boundField.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; boundField.DataField = "Value"; claimsGrid.Columns.Add(boundField); for (int i = 0; i < claimsGrid.Columns.Count; i++) { claimsGrid.Columns[i].ItemStyle.Wrap = true; // Distribute the columns evenly claimsGrid.Columns[i].ItemStyle.Width = Unit.Percentage(100 / claimsGrid.Columns.Count); } claimsGrid.DataBind(); this.Controls.Add(claimsGrid); } }
protected override void CreateChildControls() { Controls.Add(new Literal { Text = "<br/><h3>Asgard Pantheon</h3>" }); DataTable table = GetSource(); table.DefaultView.Sort = "Gender"; _gridView = new SPGridView(); _gridView.ID = "_gridView"; _gridView.AutoGenerateColumns = false; _gridView.Width = new Unit(100, UnitType.Pixel); _gridView.DataSource = table.DefaultView; _gridView.AllowGrouping = true; // le quitamos el view state _gridView.EnableViewState = false; // agrupamos por el campo "Gender" del DataSource _gridView.GroupField = "Gender"; // un nombre bonito para el campo _gridView.GroupFieldDisplayName = "Gender"; // permitimos que los grupos generados colapsen _gridView.AllowGroupCollapse = true; // adicionalmente, podemos añadir algún campo descriptivo o una imagen // _gridView.GroupDescriptionField = "Mi Campo Descriptivo"; // _gridView.GroupImageUrlField = "Mi campo con imagen"; _gridView.Columns.Add(new CommandField { ButtonType = ButtonType.Image, ShowSelectButton = true, SelectImageUrl = string.Format("{0}/asgard/_layouts/images/arrowright_light.gif", SPContext.Current.Web.Url) }); _gridView.Columns.Add(new SPBoundField { DataField = "Name", HeaderText = "Nombre" }); _gridView.Columns.Add(new SPBoundField { DataField = "Influence", HeaderText = "Influencia" }); _gridView.Columns.Add(new SPBoundField { DataField = "Comments", HeaderText = "Comentarios" }); _gridView.DataBind(); Controls.Add(_gridView); Controls.Add(new Literal { Text = "<hr/>" }); }
public void BindGrid(SPGridView grid) { SPBoundField fldPropertyName = new SPBoundField(); fldPropertyName.HeaderText = "Property Name"; fldPropertyName.DataField = "PropertyName"; grid.Columns.Add(fldPropertyName); SPBoundField fldPropertyValue = new SPBoundField(); fldPropertyValue.HeaderText = "Value"; fldPropertyValue.DataField = "PropertyValue"; grid.Columns.Add(fldPropertyValue); grid.DataSource = PropertyCollection.DefaultView; grid.DataBind(); }
private void BindDataToCustomControls() { using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { switch (_type) { case "维修保养": spgvMaterial.DataSource = from a in db.SrinMaterialRepairDetails where a.SrinRepairPlanID == _formid select new { a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.MaterialInfo.MaterialName, a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.MaterialInfo.SpecificationModel, a.ManufactureID, a.ArrivalTime, RetrieveInQuantity = a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.TotleGentaojian, a.Gentaojian, a.RepairReason, a.PlanTime, a.RealTime, a.RealGentaojian, a.Remark, a.SrinMaterialRepairDetailsID }; break; case "回收检验": spgvMaterial.DataSource = from a in db.SrinMaterialVerifyDetails where a.SrinVerifyTransferID == _formid select new { a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.MaterialInfo.MaterialName, a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.MaterialInfo.SpecificationModel, a.ManufactureID, a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.TotleGentaojian, a.SrinDetails.SrinStocktakingDetails.StorageInfo.StorageName, a.SrinDetails.SrinStocktakingDetails.PileInfo.PileName, a.RetrieveTime, a.Remark, a.SrinMaterialVerifyDetailsID }; break; } spgvMaterial.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dt = new DataTable(); dt.Columns.Add("server"); dt.Columns.Add("selected", typeof(bool)); string epmliveservers = ""; ArrayList arrServers = new ArrayList(); try { epmliveservers = SPFarm.Local.Properties["EPMLiveServers"].ToString(); foreach (string epmliveserver in epmliveservers.Split(',')) { if (epmliveserver != "") { arrServers.Add(epmliveserver); } } } catch { } SPSecurity.RunWithElevatedPrivileges(delegate() { SPServerCollection servers = SPFarm.Local.Servers; foreach (SPServer server in servers) { if (server.Role == SPServerRole.WebFrontEnd || server.Role == SPServerRole.Application) { if (arrServers.Contains(server.Name.ToLower())) { dt.Rows.Add(new object[] { server.Name, true }); } else { dt.Rows.Add(new object[] { server.Name, false }); } } } }); GvItems.DataSource = dt; GvItems.DataBind(); } }
private void BindDataToCustomControls() { using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { //初始化表头 SrinRepairPlan srp = db.SrinRepairPlan.SingleOrDefault(u => u.SrinRepairPlanID == _formid); ((Label)GetControltByMaster("lblMaterial")).Text = srp.EmpInfo.EmpName; ((Label)GetControltByMaster("lblDate")).Text = string.Concat(srp.CreateTime.ToLongDateString(), srp.CreateTime.ToLongTimeString()); ((Label)GetControltByMaster("lblCode")).Text = srp.SrinRepairPlanCode; spgvMaterial.DataSource = from a in db.SrinMaterialRepairDetails where a.SrinRepairPlanID == _formid select new { a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.MaterialInfo.MaterialName, a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.MaterialInfo.SpecificationModel, a.Manufacturer.ManufacturerName, a.ArrivalTime, a.Gentaojian, a.RepairReason, a.PlanTime, a.RealGentaojian, a.RealTime, a.Remark }; spgvMaterial.DataBind(); if (smra != null)//已经审核的情况 { if (!Page.IsPostBack) { if (smra.AuditResult.Equals("未通过")) { txtOpinion.Text = smra.AuditOpinion; txtOpinion.Enabled = true; chbAgree.AutoPostBack = false; chbAgree.Checked = false; chbAgree.AutoPostBack = true; } } } } }
private string buildProjectGrid() { PopulateDataTable(); gvPJSummary = new SPGridView { AutoGenerateColumns = false }; AddProjectNameColumn(); AddStartColumn(); AddFinishColumn(); AddPercentCompleteColumn(); AddLateTasksColumn(); AddScheduleStatusColumn(); AddIssueStatusColumn(); AddRiskStatusColumn(); SetGridViewProperties(); projectList = site.Lists["Project Center"]; string noTasksListFound = string.Empty; if (GetTasksLists(ref noTasksListFound)) { return(noTasksListFound); } issueList = site.Lists["Issues"]; riskList = site.Lists["Risks"]; ProcessIssueStatusFields(); ProcessRiskStatusFields(); var fieldGuid = projectList.Fields.GetFieldByInternalName(MyState).Id; ProcessProjectFields(fieldGuid); gvPJSummary.DataSource = dt; gvPJSummary.DataBind(); return(string.Empty); }
private void BindDataToCustomControls() { using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { //初始化表头 SrinRepairPlan srp = db.SrinRepairPlan.SingleOrDefault(u => u.SrinRepairPlanID == _formid); ((Label)GetControltByMaster("lblMaterial")).Text = srp.EmpInfo.EmpName; ((Label)GetControltByMaster("lblDate")).Text = string.Concat(srp.CreateTime.ToLongDateString(), srp.CreateTime.ToLongTimeString()); ((Label)GetControltByMaster("lblCode")).Text = srp.SrinRepairPlanCode; spgvMaterial.DataSource = from a in db.SrinMaterialRepairDetails where a.SrinRepairPlanID == _formid select new { a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.MaterialInfo.MaterialName, a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.MaterialInfo.SpecificationModel, a.ManufactureID, a.ArrivalTime, RetrieveInQuantity = a.SrinDetails.SrinStocktakingDetails.SrinSubDetails.TotleGentaojian, a.Gentaojian, a.RepairReason, a.PlanTime, a.RealGentaojian, a.RealTime, a.Remark, a.SrinMaterialRepairDetailsID }; spgvMaterial.DataBind(); //初始化审核信息 SrinMaterialRepairAudit smra = db.SrinMaterialRepairAudit.SingleOrDefault(u => u.TaskID == _pretaskid); ((Label)GetControltByMaster("lblMChief")).Text = smra.EmpInfo.EmpName; ((Label)GetControltByMaster("lblAuditDate")).Text = string.Concat(smra.AuditTime.ToLongDateString(), smra.AuditTime.ToLongTimeString()); ((Label)GetControltByMaster("lblResult")).Text = smra.AuditResult; ((TextBox)GetControltByMaster("txtOpinion")).Text = smra.AuditOpinion; } }
private void BindToSPGridView(SPGridView gridView, System.Data.DataView childView) { SPBoundField boundField; List<string> fieldsList = new List<string>() {"ExpenseType", "GLAccount", "CostCenter", "ApprovedRmbAmt" }; foreach (string fieldsName in fieldsList) { boundField = new SPBoundField(); boundField.HeaderText = fieldsName; boundField.DataField = fieldsName; gridView.Columns.Add(boundField); } HiddenField hidWorkflowID = (HiddenField)gridView.Parent.FindControl("hidWorkflowID"); //gridView.NamingContainer.Controls.Add(hidWorkflowID); gridView.DataSource = childView; gridView.PagerTemplate = null; gridView.DataBind(); }
// populate your webpart protected override void OnLoad(EventArgs e) { tbl = new Table(); tbl.ID = "tblControls"; tbl.Width = new Unit(TableWidth); TableCell cell; TableRow row; // lable showing the sql lblDescr = new Label(); lblDescr.ID = "lblDescr"; lblDescr.Text = "Sharepoint Data Webpart using SQL Statement:<p/>" + SQLString + "<p/>"; cell = new TableCell(); cell.ID = "tcDescr1"; cell.Controls.Add(lblDescr); row = new TableRow(); row.Cells.Add(cell); row.ID = "rDescr"; tbl.Rows.Add(row); // the gridview spgv = new SPGridView(); spgv.ID = "gvProducts"; //spgv.AutoGenerateSelectButton = true; // hook the event handler // spgv.SelectedIndexChanging += RowSelected; // bind the data DataTable dt = GetProductsTable(); spgv.DataSource = dt; // SPGridView does not support auto generate columns spgv.AutoGenerateColumns = false; BoundField fld = null; foreach (DataColumn dc in dt.Columns) { fld = new BoundField(); fld.DataField = dc.ColumnName; fld.HeaderText = dc.ColumnName; fld.HtmlEncode = false; spgv.Columns.Add(fld); } // SPGridView supports grouping spgv.AllowGrouping = true; spgv.GroupField = "Subcategory"; spgv.GroupFieldDisplayName = "Subcategory"; spgv.DataBind(); cell = new TableCell(); cell.ID = "tcGVCell"; cell.Controls.Add(spgv); row = new TableRow(); row.ID = "rGVRow"; row.Cells.Add(cell); tbl.Rows.Add(row); // lable showing the selection from the gridview lblSelection = new Label(); cell = new TableCell(); cell.ID = "tcSelection"; cell.Controls.Add(lblSelection); row = new TableRow(); row.ID = "rSelection"; row.Cells.Add(cell); tbl.Rows.Add(row); Controls.Add(tbl); }
protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("Title"); dt.Columns.Add("Version"); dt.Columns.Add("dtModified"); string [] v = getVersion("EPM Live Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"); if (v[0] != "") { dt.Rows.Add("Core", v[0], v[1]); } v = getVersion("EPMLiveWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"); if (v[0] != "") { dt.Rows.Add("WebParts", v[0], v[1]); } v = getVersion("EPMLiveWorkplanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"); if (v[0] != "") { dt.Rows.Add("WorkPlanner", v[0], v[1]); } v = getVersion("EPMLiveSynch, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3ef432eb7a3c56f7"); if (v[0] != "") { dt.Rows.Add("Administration Synch", v[0], v[1]); } v = getVersion("TimeSheets, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"); if (v[0] != "") { dt.Rows.Add("Timesheets", v[0], v[1]); } v = getVersion("Dashboard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"); if (v[0] != "") { dt.Rows.Add("Dashboards", v[0], v[1]); } v = getVersion("GettingStarted, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"); if (v[0] != "") { dt.Rows.Add("Getting Started", v[0], v[1]); } v = getVersion("EPMLiveEnterprise, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"); if (v[0] != "") { dt.Rows.Add("Enterprise Core", v[0], v[1]); } v = getVersion("EPMLiveReportsAdmin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b90e532f481cf050"); if (v[0] != "") { dt.Rows.Add("Reporting", v[0], v[1]); } v = getVersion("PortfolioEngineCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"); if (v[0] != "") { dt.Rows.Add("PortfolioEngine Core", v[0], v[1]); } v = getVersion("WorkEnginePPM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"); if (v[0] != "") { dt.Rows.Add("PortfolioEngine SharePoint", v[0], v[1]); } v = getVersion("EPMLiveAgilePlanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b9080c111c219f0"); if (v[0] != "") { dt.Rows.Add("Agile Planner", v[0], v[1]); } GvItems.DataSource = dt; GvItems.DataBind(); }
private void loadListGrid(string sLists, SPSite site) { DataTable dt = new DataTable(); dt.Columns.Add("ListName"); dt.Columns.Add("EditLink"); dt.Columns.Add("SyncOptions"); dt.Columns.Add("DeleteLink"); dt.Columns.Add("SyncLink"); dt.Columns.Add("LastSync"); dt.Columns.Add("Status"); dt.Columns.Add("Results"); dt.Columns.Add("ListGuid"); dt.Columns.Add("Percent"); int cntFields = 0; string[] arrLists = sLists.Split(chrPipeSeparator, StringSplitOptions.RemoveEmptyEntries); SqlConnection cn = new SqlConnection(); SPSecurity.RunWithElevatedPrivileges(delegate() { cn.ConnectionString = EPMLiveCore.CoreFunctions.getConnectionString(site.WebApplication.Id); cn.Open(); }); foreach (string sListID in arrLists) { string sListName = ""; string sListGuid = ""; string sListEditPageURL = ""; try { SPList lst = currWeb.Lists[new Guid(sListID)]; sListName = lst.Title; sListGuid = lst.ID.ToString(); } catch { } if (sListGuid.Length != 0) { sListEditPageURL = currWeb.Url + "/_layouts/ListEdit.aspx?List={" + sListGuid + "}&Source=" + currWeb.Url + "/_layouts/epmlive/templates.aspx"; string sSiteGuid = ""; sSiteGuid = currWeb.Site.ID.ToString(); string sServerRelativeUrl = currWeb.ServerRelativeUrl; //if (currWeb.ServerRelativeUrl.Trim() == "/") //{ // sServerRelativeUrl = ""; //} //else //{ // sServerRelativeUrl = currWeb.ServerRelativeUrl; //} SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select timerjobuid,runtime,percentComplete,status,dtfinished,result From vwQueueTimerLog Where listguid=@listguid and jobtype=4"; cmd.Parameters.AddWithValue("@listguid", sListGuid); cmd.Connection = cn; SqlDataReader rdr; rdr = cmd.ExecuteReader(); string sImg = ""; string sLogTime = ""; string sLogResult = ""; string percent = "0"; if (rdr.Read()) { if (!rdr.IsDBNull(3)) { if (rdr.GetInt32(3) == 0) { sLogResult = "Queued"; } else if (rdr.GetInt32(3) == 1) { sLogResult = "Processing"; percent = rdr.GetInt32(2).ToString("##0"); } else if (!rdr.IsDBNull(5)) { sLogResult = rdr.GetString(5); if (sLogResult == "No Errors") { sImg = "<img src=\"/_layouts/images/green.gif\" alt=\"\" >"; } else { sImg = "<img src=\"/_layouts/images/yellow.gif\" alt=\"\" >"; } } else { sLogResult = "No Results"; } } if (!rdr.IsDBNull(4)) { sLogTime = rdr.GetDateTime(4).ToString(); } } rdr.Close(); dt.Rows.Add(new string[] { sListName, sListEditPageURL, "", "", "", sLogTime, sImg, sLogResult, sListGuid, percent }); cntFields++; ////bool processing = false; ////if (rdr.Read()) ////{ //// if (rdr.GetInt32(0) == 0) //// { //// processing = true; //// sLogResult = "Queued"; //// } //// else if (rdr.GetInt32(0) == 1) //// { //// processing = true; //// sLogResult = "Processing"; //// } //// percent = rdr.GetInt32(1).ToString("##0"); //// if (!rdr.IsDBNull(2)) //// { //// sLogTime = rdr.GetDateTime(2).ToString(); //// } ////} ////rdr.Close(); ////if (!processing) ////{ //// cmd = new SqlCommand(); //// cmd.CommandText = "Select result From epmlive_log Where listguid=@listguid and log_type=4"; //// cmd.Parameters.AddWithValue("@listguid", sListGuid); //// cmd.Connection = cn; //// rdr = cmd.ExecuteReader(); //// if (rdr.Read()) //// { //// sLogResult = rdr.GetString(0); //// if (sLogResult.Contains("No Errors")) //// { //// sImg = "<img src=\"/_layouts/images/green.gif\" alt=\"\" >"; //// } //// else //// { //// sImg = "<img src=\"/_layouts/images/yellow.gif\" alt=\"\" >"; //// } //// } //// rdr.Close(); ////} /* * if (rdr.Read()) * { * sLogResult = rdr.GetString(0); * sLogTime = rdr.GetDateTime(1).ToLocalTime().ToString(); * if(!rdr.IsDBNull(2)) * percent = rdr.GetDouble(2).ToString("##0"); * } * rdr.Close(); * * //if (sLastResults.Length > 0 && sLastResults.IndexOf("Log time:") > 0) * //{ * // sLogResult = sLastResults.Substring(0, sLastResults.IndexOf("Log time:") - 2); * // sLogTime = sLastResults.Substring(sLastResults.IndexOf("Log time:") + 10); * DateTime dtLogTime; * if (DateTime.TryParse(sLogTime, out dtLogTime)) * { * if (sMaxListSyncDate == "") * { * sMaxListSyncDate = dtLogTime.ToString(); * } * else * { * DateTime dtMaxListSyncDate; * if (DateTime.TryParse(sLogTime, out dtLogTime) && DateTime.TryParse(sMaxListSyncDate, out dtMaxListSyncDate)) * { * if (dtLogTime.CompareTo(dtMaxListSyncDate) > 0) * { * sMaxListSyncDate = dtLogTime.ToShortDateString() + " " + dtLogTime.ToLongTimeString(); * } * } * } * } * //} * * * * if (sLogResult.Contains("Success") || sLogResult == "" || sLogResult.Contains("Processing")) * { * sImg = "<img src=\"/_layouts/images/green.gif\" alt=\"\" >"; * } * else * { * sImg = "<img src=\"/_layouts/images/yellow.gif\" alt=\"\" >"; * } */ DateTime dtLogTime; if (DateTime.TryParse(sLogTime, out dtLogTime)) { if (sMaxListSyncDate == "") { sMaxListSyncDate = dtLogTime.ToString(); } else { DateTime dtMaxListSyncDate; if (DateTime.TryParse(sLogTime, out dtLogTime) && DateTime.TryParse(sMaxListSyncDate, out dtMaxListSyncDate)) { if (dtLogTime.CompareTo(dtMaxListSyncDate) > 0) { sMaxListSyncDate = dtLogTime.ToShortDateString() + " " + dtLogTime.ToLongTimeString(); } } } } } } cn.Close(); //if (cntFields > 0) gvLists.PageSize = cntFields; gvLists.DataSource = dt; gvLists.DataBind(); }
public static void HandleGridPermanentAddClickEvent( StateBag viewState, ref DataTable groupsPermissions, DropDownList groupsDropDownList, DropDownList spPermissionsDropDownList, SPGridView gvGroupsPermissions, Button button) { if (viewState == null) { throw new ArgumentNullException(nameof(viewState)); } if (groupsDropDownList == null) { throw new ArgumentNullException(nameof(groupsDropDownList)); } if (spPermissionsDropDownList == null) { throw new ArgumentNullException(nameof(spPermissionsDropDownList)); } if (gvGroupsPermissions == null) { throw new ArgumentNullException(nameof(gvGroupsPermissions)); } if (button == null) { throw new ArgumentNullException(nameof(button)); } if (viewState["dtGroupsPermissions"] != null) { groupsPermissions = (DataTable)viewState["dtGroupsPermissions"]; var dataRow = groupsPermissions.NewRow(); dataRow["GroupsText"] = groupsDropDownList.Items[groupsDropDownList.SelectedIndex].Text; dataRow["GroupsID"] = groupsDropDownList.Items[groupsDropDownList.SelectedIndex].Value; dataRow["PermissionsText"] = spPermissionsDropDownList.Items[spPermissionsDropDownList.SelectedIndex].Text; dataRow["PermissionsID"] = spPermissionsDropDownList.Items[spPermissionsDropDownList.SelectedIndex].Value; var blnRecordExists = false; foreach (DataRow row in groupsPermissions.Rows) { if ($"{row["GroupsID"]};{row["PermissionsID"]}" == $"{groupsDropDownList.Items[groupsDropDownList.SelectedIndex].Value};{spPermissionsDropDownList.Items[spPermissionsDropDownList.SelectedIndex].Value}" ) { blnRecordExists = true; break; } } if (!blnRecordExists) { groupsPermissions.Rows.Add(dataRow); gvGroupsPermissions.DataSource = groupsPermissions; gvGroupsPermissions.DataBind(); viewState["dtGroupsPermissions"] = groupsPermissions; } } button.Focus(); }
private void GetInfo() { try { var web = SPContext.Current.Web; { using (var sqlConnection = new SqlConnection(CoreFunctions.getConnectionString(WebApplicationSelector1.CurrentItem.Id))) { SPSecurity.RunWithElevatedPrivileges(delegate { sqlConnection.Open(); }); using (var selectCountCommand = new SqlCommand("select count(*) from queue where status = 0", sqlConnection)) { using (var dataReader = selectCountCommand.ExecuteReader()) { lblLength.Text = "0"; if (dataReader.Read()) { lblLength.Text = dataReader.GetInt32(0).ToString(); } } } using (var selectQueueStatsCommand = new SqlCommand("select * from vwQueueStats", sqlConnection)) { using (var dataReader = selectQueueStatsCommand.ExecuteReader()) { lblWait.Text = string.Empty; lblJobTime.Text = string.Empty; lblMaxQueue.Text = string.Empty; lblMaxJob.Text = string.Empty; lblTotalJobs.Text = string.Empty; if (dataReader.Read()) { if (!dataReader.IsDBNull(0)) { lblJobTime.Text = showtime(dataReader.GetInt32(0)); } if (!dataReader.IsDBNull(1)) { lblWait.Text = showtime(dataReader.GetInt32(1)); } if (!dataReader.IsDBNull(2)) { lblMaxJob.Text = showtime(dataReader.GetInt32(2)); } if (!dataReader.IsDBNull(3)) { lblMaxQueue.Text = showtime(dataReader.GetInt32(3)); } if (!dataReader.IsDBNull(4)) { lblTotalJobs.Text = dataReader.GetInt32(4).ToString(); } } } } using (var selectQueueStatusOrderedCommand = new SqlCommand( "select * from vwQueueItems order by status, dtfinished desc", sqlConnection)) { using (var dataAdapter = new SqlDataAdapter(selectQueueStatusOrderedCommand)) { using (var dataSet = new DataSet()) { dataAdapter.Fill(dataSet); GvItems.DataSource = dataSet.Tables[0]; } } } GvItems.DataBind(); } } } catch (Exception ex) { System.Diagnostics.Trace.TraceError("Exception suppressed: {0}", ex); } }
private void BindToSPGridView(SPGridView gridView, System.Data.DataView childView) { SPBoundField boundField; List<string> fieldsList = new List<string>() { "ExpenseType", "CostCenter", "ItemAmount", "GLAccount" }; foreach (string fieldsName in fieldsList) { boundField = new SPBoundField(); string headerText = fieldsName; //if (fieldsName == "EECWWorkflowNumber") //{ // headerText = "WorkflowNumber"; //} if (fieldsName == "ItemAmount") { headerText = "Amount"; } boundField.HeaderText = headerText; boundField.DataField = fieldsName; gridView.Columns.Add(boundField); } //HiddenField hidWorkflowID = (HiddenField)gridView.Parent.FindControl("hidWorkflowID"); //gridView.NamingContainer.Controls.Add(hidWorkflowID); gridView.DataSource = childView; gridView.PagerTemplate = null; gridView.DataBind(); }
public void BindGrid(SPGridView grid) { grid.DataSource = PropertyCollection.DefaultView; grid.DataBind(); }
public string buildData2() { dt = new DataTable(); dt.Columns.Add("name"); dt.Columns.Add("pctcomplete"); dt.Columns.Add("latetasks"); dt.Columns.Add("schedulestatus"); dt.Columns.Add("issuestatus"); dt.Columns.Add("riskstatus"); gvPJSummary2 = new SPGridView(); gvPJSummary2.AutoGenerateColumns = false; var colTitle = new BoundField(); colTitle.DataField = "name"; colTitle.HeaderText = "Project Name"; colTitle.HtmlEncode = false; gvPJSummary2.Columns.Add(colTitle); colTitle = new BoundField(); colTitle.DataField = "pctcomplete"; colTitle.HeaderText = "% Complete"; colTitle.ItemStyle.HorizontalAlign = HorizontalAlign.Center; gvPJSummary2.Columns.Add(colTitle); colTitle = new BoundField(); colTitle.DataField = "schedulestatus"; colTitle.HeaderText = "Schedule"; colTitle.HtmlEncode = false; colTitle.ItemStyle.HorizontalAlign = HorizontalAlign.Center; gvPJSummary2.Columns.Add(colTitle); colTitle = new BoundField(); colTitle.DataField = "issuestatus"; colTitle.HeaderText = "Issues"; colTitle.HtmlEncode = false; colTitle.ItemStyle.HorizontalAlign = HorizontalAlign.Center; gvPJSummary2.Columns.Add(colTitle); colTitle = new BoundField(); colTitle.DataField = "riskstatus"; colTitle.HeaderText = "Risks"; colTitle.HtmlEncode = false; colTitle.ControlStyle.CssClass = "ms-vh"; colTitle.ItemStyle.HorizontalAlign = HorizontalAlign.Center; gvPJSummary2.Columns.Add(colTitle); gvPJSummary2.AllowGrouping = false; gvPJSummary2.ID = "gvPJSummary"; gvPJSummary2.Width = Unit.Percentage(100); gvPJSummary2.HeaderStyle.CssClass = "ms-vh"; projectList = site.Lists["Project Center"]; try { taskList = site.Lists["Task Center"]; } catch { try { taskList = site.Lists["My Tasks"]; return ("In order to take advantage of the new EPM Live functionality, please follow the instructions located <a href=\"http://www.projectpublisher.com/downloads/ProjectPublisherUpdateProcess.pdf\" target=\"_blank\">here</a>."); } catch (Exception ex) { Trace.TraceError("Exception Suppressed {0}", ex); return("No Tasks List Found"); } } issueList = site.Lists["Issues"]; riskList = site.Lists["Risks"]; foreach (SPListItem listItem in projectList.Items) { try { if (listItem["State"].ToString() == "(2) Active") { processProjectSummaryItem2(listItem); } } catch (Exception ex) { Trace.TraceError("Exception Suppressed {0}", ex); } } gvPJSummary2.DataSource = dt; gvPJSummary2.DataBind(); return(string.Empty); }
protected override void Render(HtmlTextWriter writer) { //WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site); WBTaxonomy seriesTags = WBTaxonomy.GetSeriesTags(SPContext.Current.Site); WBTerm seriesTag = null; if (SeriesTag != null && SeriesTag != "") { Term seriesTagTerm = seriesTags.GetSelectedTermByPath(SeriesTag); if (seriesTagTerm != null) { seriesTag = new WBTerm(seriesTags, seriesTagTerm); } } WBQuery query = new WBQuery(); //query.AddEqualsFilter(WBColumn.RecordsType, workBox.RecordsType); if (seriesTag != null) { query.AddEqualsFilter(WBColumn.SeriesTag, seriesTag); } if (ReferenceID != null && ReferenceID != "") { query.AddEqualsFilter(WBColumn.ReferenceID, ReferenceID); } // if (FilterByOwningTeam) // query.AddEqualsFilter(WBColumn.OwningTeam, workBox.OwningTeam); if (sortColumn != null) { WBLogging.Debug("Sorting in Render with sortColumn: " + sortColumn.DisplayName); } else { WBLogging.Debug("SortColumn was null - so sorting by declared record date."); sortColumn = WBColumn.DeclaredRecord; ascending = false; } if (sortColumn != null) { query.OrderBy(sortColumn, ascending); } query.AddViewColumn(WBColumn.Name); query.AddViewColumn(WBColumn.FileTypeIcon); query.AddViewColumn(WBColumn.EncodedAbsoluteURL); query.AddViewColumn(WBColumn.ReferenceDate); query.AddViewColumn(WBColumn.ProtectiveZone); query.AddViewColumn(WBColumn.DeclaredRecord); WBFarm farm = WBFarm.Local; using (SPSite site = new SPSite(farm.ProtectedRecordsLibraryUrl)) { using (SPWeb web = site.OpenWeb()) { SPList recordsLibrary = web.GetList(farm.ProtectedRecordsLibraryUrl); DataTable dataTable = recordsLibrary.WBxGetDataTable(site, query, MaxNumDocuments); gridView.DataSource = dataTable; gridView.Columns.Clear(); gridView.Columns.Add(WBUtils.DynamicIconTemplateField(WBColumn.FileTypeIcon, WBColumn.EncodedAbsoluteURL)); gridView.Columns.Add(WBUtils.HyperLinkField(WBColumn.Name, WBColumn.EncodedAbsoluteURL, sortColumn, ascending)); gridView.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, sortColumn, ascending)); gridView.Columns.Add(WBUtils.BoundField(WBColumn.ProtectiveZone, sortColumn, ascending)); gridView.Columns.Add(WBUtils.BoundField(WBColumn.DeclaredRecord, sortColumn, ascending)); gridView.DataBind(); } } base.Render(writer); }
protected override void Render(HtmlTextWriter writer) { WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox == null) { errorLiteral.Text = "<i>(You can only use this web part in a work box)</i>"; } else { WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site); WBTaxonomy seriesTags = WBTaxonomy.GetSeriesTags(recordsTypes); WBTerm thisSeries = workBox.SeriesTag(seriesTags); WBQuery query = new WBQuery(); query.AddEqualsFilter(WBColumn.RecordsType, workBox.RecordsType); if (FilterBySeriesTag) { query.AddEqualsFilter(WBColumn.SeriesTag, workBox.SeriesTag(seriesTags)); } if (FilterByReferenceID) { query.AddEqualsFilter(WBColumn.ReferenceID, workBox.ReferenceID); } // if (FilterByOwningTeam) // query.AddEqualsFilter(WBColumn.OwningTeam, workBox.OwningTeam); if (sortColumn != null) { WBLogging.Debug("Sorting in Render with sortColumn: " + sortColumn.DisplayName); } else { WBLogging.Debug("Sorting Render - sortColumn was null"); } if (sortColumn != null) { query.OrderBy(sortColumn, ascending); } query.AddViewColumn(WBColumn.Title); query.AddViewColumn(WBColumn.WorkBoxURL); query.AddViewColumn(WBColumn.ReferenceDate); query.AddViewColumn(WBColumn.WorkBoxStatus); WBColumn testIfIsThisWorkBox = new WBColumn("IfIsThisWorkBox", WBColumn.DataTypes.VirtualConditional); testIfIsThisWorkBox.TestColumnInternalName = WBColumn.Title.InternalName; testIfIsThisWorkBox.TestColumnValue = workBox.Title; testIfIsThisWorkBox.ValueIfEqual = "===>"; query.AddViewColumn(testIfIsThisWorkBox); DataTable dataTable = workBox.Collection.Query(query); gridView.DataSource = new DataView(dataTable); BoundField testIfIsThisWorkBoxField = WBUtils.BoundField(testIfIsThisWorkBox, HorizontalAlign.Center, sortColumn, ascending); testIfIsThisWorkBoxField.HeaderText = " "; gridView.Columns.Add(testIfIsThisWorkBoxField); gridView.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL)); gridView.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending)); gridView.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, sortColumn, ascending)); gridView.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, HorizontalAlign.Center, sortColumn, ascending)); gridView.DataBind(); if (ShowCreateNewLink) { string createNewText = workBox.RecordsType.CreateNewWorkBoxText; string createNewURL = workBox.Collection.GetUrlForNewDialog(workBox, WorkBox.RELATION_TYPE__DYNAMIC); createNewLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 600, 500); \">" + createNewText + "</a>"; } workBox.Dispose(); } base.Render(writer); }
private void BindToSPGridView(SPGridView gridView, System.Data.DataView childView) { SPBoundField boundField; List<string> fieldsList = new List<string>() { "ExpenseType", "CostCenter", "DealAmount", "AmountType", "GLAccount"}; foreach (string fieldsName in fieldsList) { boundField = new SPBoundField(); string headerText = fieldsName; //if (fieldsName == "CCCWWorkflowNumber") //{ // headerText = "WorkflowNumber"; //} if (fieldsName == "DealAmount") { headerText = "Amount"; } if (fieldsName == "AmountType") { headerText = "Currency"; } boundField.HeaderText = headerText; boundField.DataField = fieldsName; gridView.Columns.Add(boundField); } gridView.DataSource = childView; gridView.PagerTemplate = null; gridView.DataBind(); }
// end of method public void createGridViewWithCheckBox(ref SPGridView grv) { try { DataTable dt = new DataTable(); dt.Columns.Add("internalName", typeof(string)); SPWeb web = SPContext.Current.Web; SPListCollection lists = web.Lists; DataRow row; foreach (SPList oList in lists) { if (!oList.Hidden) { row = dt.Rows.Add(); row["internalName"] = oList.Title; //if (oList.BaseType != SPBaseType.DocumentLibrary) //{ // row = dt.Rows.Add(); // row["internalName"] = oList.Title; //} //else //{ // SPDocumentLibrary oDocumentLibrary = (SPDocumentLibrary)oList; // // if (!oDocumentLibrary.IsCatalog && oList.BaseTemplate != SPListTemplateType.XMLForm && oList.BaseTemplate != SPListTemplateType.WebPageLibrary && ) //if (oList.BaseType == SPBaseType.DocumentLibrary) //{ // SPDocumentLibrary oDocumentLibrary = (SPDocumentLibrary)oList; // if (!oDocumentLibrary.IsCatalog && oList.BaseTemplate == SPListTemplateType.DocumentLibrary) // { // //SPListItemCollection collListItems = oDocumentLibrary.Items; // string testName = ""; // //foreach (SPListItem oListItem in collListItems) // //{ // // testName += oListItem.Name + "--" + oListItem.DisplayName + "--" + oListItem.File.Title; // //} // //string title2 = testName; // SPListItemCollection folders = oDocumentLibrary.Folders; // //foreach (SPListItem folder in folders) // //{ // // string link = folder.Url; // // string displayName = folder.DisplayName; // //} // //foreach (SPListItem item in oDocumentLibrary.Items) // //{ // // //string sFileLink = item.Url; // // //string fileName = item.DisplayName; // // SPFile oFile = item.File; // // string sFileLink = oFile.ServerRelativeUrl; // // string fileName = oFile.ParentFolder.Name; // //} // //foreach (SPFolderCollection folders in oDocumentLibrary.RootFolder.SubFolders) // //{ // // //string sTempFolderName = fItem.Name; // // foreach (SPFolder item in folders) // // { // // string sURL = item.Url; // // string sLink = sURL + item.Title; // // } // //} // } //} //} } } TemplateField selectTaskColumn = new TemplateField(); selectTaskColumn.HeaderText = ""; selectTaskColumn.ItemTemplate = new CheckBoxTemplate(ListItemType.Item, "", ""); grv.Columns.Add(selectTaskColumn); SPBoundField field; field = new SPBoundField(); //field. field.HeaderText = "List & Libraries"; field.DataField = "internalName"; field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; field.ItemStyle.HorizontalAlign = HorizontalAlign.Left; field.ItemStyle.Wrap = false; //grv.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; grv.Columns.Add(field); TemplateField displayListColumn = new TemplateField(); displayListColumn.ItemTemplate = new CheckBoxTemplate(ListItemType.EditItem, "", "test"); displayListColumn.HeaderText = "Display Name"; displayListColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; grv.Columns.Add(displayListColumn); grv.AutoGenerateColumns = false; grv.DataSource = dt.DefaultView; grv.DataBind(); } catch { } }
protected void Page_Load(object sender, EventArgs e) { if (Request["delete"] != "") { EPMLiveCore.CoreFunctions.deleteKey(Request["delete"]); } MenuTemplate propertyNameListMenu = new MenuTemplate(); propertyNameListMenu.ID = "PropertyNameListMenu"; MenuItemTemplate testMenu = new MenuItemTemplate( "Delete Key", "/_layouts/images/delete.gif"); testMenu.ClientOnClickNavigateUrl = "features.aspx?delete=%NAME%"; propertyNameListMenu.Controls.Add(testMenu); this.Controls.Add(propertyNameListMenu); DataTable dt = new DataTable(); dt.Columns.Add("feature"); dt.Columns.Add("company"); dt.Columns.Add("features"); dt.Columns.Add("users"); dt.Columns.Add("servers"); dt.Columns.Add("dtcreated"); dt.Columns.Add("expiration"); int servercount = 0; string[] features = EPMLiveCore.CoreFunctions.featureList(); foreach (string feature in features) { string[] featureData = EPMLiveCore.CoreFunctions.Decrypt(feature, "jLHKJH5416FL>1dcv3#I").Split('\n'); if (featureData[2] == "0") { featureData[2] = "Unlimited"; } string[] featureNames = featureData[1].Split(','); string featureRealName = ""; string servers = ""; try { servers = featureData[5]; servercount += int.Parse(servers); }catch {} foreach (string featureName in featureNames) { featureRealName += CoreFunctions.getFeatureName(featureName); } if (featureRealName.Length > 0) { featureRealName = featureRealName.Substring(4); } if (featureData[0][0] == '*') { dt.Rows.Add(new string[] { HttpUtility.UrlEncode(feature), featureData[2], featureRealName, featureData[2], servers, DateTime.Parse(featureData[1]).ToShortDateString(), featureData[4] }); } else { dt.Rows.Add(new string[] { HttpUtility.UrlEncode(feature), featureData[0], featureRealName, featureData[2], servers, featureData[3], featureData[4] }); } } GvItems.DataSource = dt; GvItems.DataBind(); DataTable dt2 = new DataTable(); dt2.Columns.Add("featureid"); dt2.Columns.Add("feature"); dt2.Columns.Add("quantity"); dt2.Columns.Add("active"); SortedList acts = Act.GetAllAvailableLevels(out actType); ArrayList arrUsers = new ArrayList(); if (actType == 3) { MenuTemplate propertyNameListMenu2 = new MenuTemplate(); propertyNameListMenu2.ID = "PropertyNameListMenu2"; MenuItemTemplate testMenu2 = new MenuItemTemplate( "Manage Users", ""); testMenu2.ClientOnClickScript = "managelicv2('%NAME%');"; propertyNameListMenu2.Controls.Add(testMenu2); this.Controls.Add(propertyNameListMenu2); arrUsers = CoreFunctions.getFeatureUsers(1000); if (arrUsers.Count == 1 && arrUsers[0].ToString() == "") { arrUsers = new ArrayList(); } } else { MenuTemplate propertyNameListMenu2 = new MenuTemplate(); propertyNameListMenu2.ID = "PropertyNameListMenu2"; MenuItemTemplate testMenu2 = new MenuItemTemplate( "Manage Users", ""); //testMenu2.ClientOnClickNavigateUrl = "users.aspx?feature=%NAME%"; testMenu2.ClientOnClickScript = "managelic('%NAME%');"; propertyNameListMenu2.Controls.Add(testMenu2); this.Controls.Add(propertyNameListMenu2); } foreach (DictionaryEntry de in acts) { if (actType == 3) { int counter = 0; foreach (string user in arrUsers) { string[] sUserInfo = user.Split(':'); try { if (sUserInfo[1] == de.Key.ToString()) { counter++; } } catch { } } string count = de.Value.ToString(); if (count == "0") { count = "Unlimited"; } dt2.Rows.Add(new string[] { de.Key.ToString(), Act.GetFeatureNameV2(de.Key.ToString()), count, counter.ToString() }); } else { CoreFunctions.getFeatureLicenseUserCount(int.Parse(de.Key.ToString())); string count = de.Value.ToString(); if (count == "0") { count = "Unlimited"; } dt2.Rows.Add(new string[] { de.Key.ToString(), Act.GetFeatureName(de.Key.ToString()), count, CoreFunctions.getFeatureUsers(int.Parse(de.Key.ToString())).Count.ToString() }); } } gvFeatures.DataSource = dt2; gvFeatures.DataBind(); lblFarmId.Text = SPFarm.Local.Id.ToString(); string epmliveservers = ""; try { epmliveservers = SPFarm.Local.Properties["EPMLiveServers"].ToString(); } catch { } SPSecurity.RunWithElevatedPrivileges(delegate() { SPServerCollection servers = SPFarm.Local.Servers; int farmservercount = 0; foreach (SPServer server in servers) { if (server.Role == SPServerRole.WebFrontEnd || server.Role == SPServerRole.Application) { farmservercount++; } } if (farmservercount > servercount && servercount != 0 && epmliveservers != "") { lblWarning.Text = "<b>Warning:</b> It appears you have may have more servers in your farm than your key allows. To select specific servers go to the <a href=\"servers.aspx\">EPM Live Servers</a> page."; } }); }
protected void gvSites_PageIndexChanging(object sender, GridViewPageEventArgs e) { gvSites.PageIndex = e.NewPageIndex; gvSites.DataBind(); }
private void BindToSPGridView(SPGridView gridView, System.Data.DataView childView) { SPBoundField boundField; List<string> fieldsList = new List<string>() { "AssetNo", "ExpenseType", "CostCenter", "ItemAmount", "GLAccount" }; foreach (string fieldsName in fieldsList) { boundField = new SPBoundField(); boundField.HeaderText = fieldsName; boundField.DataField = fieldsName; gridView.Columns.Add(boundField); } gridView.DataSource = childView; gridView.PagerTemplate = null; gridView.DataBind(); }