Order of webpart properties
I have a custom o365 SPO application with a custom web part. How do change the order in which the properties show up. They show up in a different order than shown in my elements.xml file. It's VS 2013 sharepoint solution.
Hi
what about other existing web parts in office 365, try to add web part from those available already and check their order if it is the same then this is the default.
Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation. Please remember to mark the reply as answer if it helps.
Similar Messages
-
Webpart properties reset to saved when changed
Hello!
Is there any way to prevent saving of webparts?
We have a problem with our custom master-page (JS, CSS, custom webparts included) - when we save changes in any webpart and any field (and not customized too) it resets to a previously saved value. When we set default master - there is no such problem.
So we are trying to locate any places that could corrupt default saving logic, so if you can point on as many ways to prevent changes saving (using only master & custom webparts, no changes in settings) - it would be really helpful.
Or maybe someone encountered such problem before?Hi,
Based on your description, my understanding is that when you changed the webpart properties and saved it, it reset to a previously value.
As the issue only occurs with the custom master-page, maybe in the custom code the default values were being forcefully placed in the properties. So you need to troubleshot your custom master-page's code.
Here are some similar posts you can use as a reference:
https://social.msdn.microsoft.com/Forums/en-US/6bc6226b-f58a-4ac9-8da6-024c7a88258d/web-part-properties-lost-when-saving-page?forum=sharepointdevelopmentprevious
https://social.msdn.microsoft.com/Forums/en-US/5777b8fb-7251-4736-a424-220b31e8e7de/web-part-property-not-saving-value?forum=sharepointdevelopmentprevious
Best Regards,
Lisa Chen
Lisa Chen
TechNet Community Support -
Change a label in page when webpart properties are changed
Hi
can anyone please tel me how to
Change label in page when webpart properties are changed
Nishanthi NHi Nishanthi,
If it would be a Visual Webpart, then you have to pass webpart property in user control as WP property bag/collection so that you will retrieve it in ascx and assign its value to label on load event.
Add below code in Webpart:
[Personalizable(), WebBrowsable, WebDisplayName("City or Town"), Category("Address settings")]
public String City {
get; set; }
protected
override void CreateChildControls()
AddressUserControl control = Page.LoadControl(_ascxPath)
as AddressUserControl;
if
(control != null)
control.WebPart =
this;
Controls.Add(control);
Put this code in your ASCX Control:
MyWebPartClass ParentWebPart = (MyWebPartClass)this.Parent;
Use this code in your ASCX methods:
string webPartProperty = this.ParentWebPart.City;
Thanks
Please mark it as Answer if works... -
Creating Dropdown as custom webpart properties
Hi,
I have currently created a custom string (textbox) webpart property.
I would like to add another webpart property which is of dropdown model (enum). However, I am not able to create and associate a default value.
I want to create a enum as below:
public enum _ddlPager { 10, 20, 50,100 }
And also set the default value as 10.
I have already checked:
http://www.ashokraja.me/articles/How-to-create-a-custom-property-and-set-a-default-value-in-a-SharePoint-2013-Visual-WebPart
http://www.learningsharepoint.com/2013/08/22/create-custom-webpart-properties-for-sharepoint-2013-visual-webpart/
But I was not able to add the numbers.
How to create a dropdown for custom webpart property?
ThanksHi,
Thanks for the reply.
I have tried like this, but the code has errors:
#region Custom web part property
private propertyPager _ddlpropertyPager ;
public enum propertyPager
_1a = 10,
_2a = 20,
_3a = 50,
_4a = 100
[WebBrowsable(true), Personalizable(PersonalizationScope.Shared)]
public propertyPager propertyPageNumbers
get { return _ddlpropertyPager; }
set { _ddlpropertyPager = value; }
public override EditorPartCollection CreateEditorParts()
ArrayList editorArray = new ArrayList();
CustomProperty edPart = new CustomProperty();
edPart.ID = this.ID + "_editorPart1";
editorArray.Add(edPart);
EditorPartCollection editorParts = new EditorPartCollection(editorArray);
return editorParts;
public void SaveChanges()
this.SetPersonalizationDirty();
//Create a custom EditorPart to edit the WebPart control.
private class CustomProperty : EditorPart
DropDownList _ddlPager;
public CustomProperty()
Title = "Custom Properties";
public override bool ApplyChanges()
SummaryWP part = this.WebPartToEdit as SummaryWP;
part.propertyPageNumbers = ddlPage.SelectedValue.ToString();
part.SaveChanges();
return true;
public override void SyncChanges()
EnsureChildControls();
SummaryWP part = (SummaryWP)WebPartToEdit;
_ddlPager.SelectedValue = part.propertyPageNumbers;
protected override void CreateChildControls()
Controls.Clear();
_ddlPager = new DropDownList();
Controls.Add(_ddlPager);
protected override void RenderContents(HtmlTextWriter writer)
writer.Write("Items Per Page :");
writer.WriteBreak();
_ddlPager.RenderControl(writer);
writer.Write("");
writer.WriteBreak();
writer.Write("--------------------------");
private DropDownList ddlPage
get
EnsureChildControls();
return _ddlPager;
#endregion }}
Getting error in function "Apply Changes" and "Sync Changes"
How to fix this?
Thanks -
Adding an item to a List when clicking a WebPart Properties 'OK' button
Hi all,
I wonder if someone can help me. Im new to SharePoint Programming but learning slowly.
I have a superb Web Part downloaded from Codeplex which essentially is a Countdown Timer in jQuery. (spCountdown) The code itself works perfectly however I want to tweak it, in what I thought would be a relatively easy thing to do.
In the Web Part properties of the solution, there is a textbox where you enter the Date/Time which you wish to set the countdown timer. When I click 'OK' to submit the WebPart, I would like the date value in the textbox to be added to a List as a new List
item. I've got the code to add the List item (or what im think is the correct code) but what I cant do is get the function to execute when the WebPart 'OK' button is clicked.
Now, I have downloaded the source code which is available but I cant fathom how to hook the 'Update List Item' code onto the onclick event of the button (as I cant find an onclick event!). Any help to advise me what to do would be appreciated.
My code to add the date to the new List:
// create item in Deadline Configuration List
using (SPSite oSiteCollection = new SPSite(SPContext.Current.Site.Url))
using (SPWeb oWeb = oSiteCollection.OpenWeb())
SPList oList = oWeb.Lists["DLConfig"];
SPListItem oListItem = oList.Items.Add();
oListItem["Title"] = "Deadline Date";
oListItem["TaskDueDate"] = new DateTime(WebPart.TargetDate.Year, WebPart.TargetDate.Month, WebPart.TargetDate.Day);
oWeb.AllowUnsafeUpdates = true;
oListItem.Update();
Original WebPart Code:
SPCountdownWebpart.cs
using System;
using System.ComponentModel;
using System.Web.UI.WebControls.WebParts;
namespace SPCountdown.SPCountdownWebPart
[ToolboxItemAttribute(false)]
public class SPCountdownWebPart : WebPart
// Visual Studio might automatically update this path when you change the Visual Web Part project item.
private const string _ascxPath = @"~/_CONTROLTEMPLATES/SPCountdown/SPCountdownWebPart/SPCountdownWebPartUserControl.ascx";
protected override void CreateChildControls()
var control = Page.LoadControl(_ascxPath);
if (control != null)
((SPCountdownWebPartUserControl)control).WebPart = this;
Controls.Add(control);
[Category("Countdown Settings"),
Personalizable(PersonalizationScope.Shared),
WebBrowsable(true),
WebDisplayName("Target Date/Time"),
WebDescription("Please enter the target date/time for countdown.")]
public DateTime TargetDate { get; set; }
SPCountdownWebpartUserControl.cs
using System;
using System.Web.UI;
using Microsoft.SharePoint;
namespace SPCountdown.SPCountdownWebPart
public partial class SPCountdownWebPartUserControl : UserControl
public SPCountdownWebPart WebPart { get; set; }
public SPCountdownWebPartUserControl()
PreRender += SPCountdownWebPartUserControl_PreRender;
void SPCountdownWebPartUserControl_PreRender(object sender, EventArgs e)
// parse date from properties
var targetDateString = string.Format("{0},{1},{2},{3},{4},{5}",
WebPart.TargetDate.Year,
WebPart.TargetDate.Month - 1, //uses 0-based index
WebPart.TargetDate.Day,
WebPart.TargetDate.Hour,
WebPart.TargetDate.Minute,
WebPart.TargetDate.Second);
// js sources
const string jqueryScript = "<script type='text/javascript' src='/_layouts/SPCountdown/js/jquery-1.10.2.min.js'></script>";
const string countdownScript = "<script type='text/javascript' src='/_layouts/SPCountdown/js/jquery.countdown.min.js'></script>";
// create javascript implementing countdown
const string jsCountdownFormat = "<script type='text/javascript'>$(function () {{var targetDate = new Date({0});$('#defaultCountdown').countdown({{until: targetDate}});}});</script>";
var jsCountdown = string.Format(jsCountdownFormat, targetDateString);
// register client scripts
var cs = Page.ClientScript;
if (!cs.IsClientScriptBlockRegistered("jQuery"))
cs.RegisterClientScriptBlock(
GetType(),
"jQuery",
jqueryScript);
if (!cs.IsClientScriptBlockRegistered("jsCountdownScript"))
cs.RegisterClientScriptBlock(
GetType(),
"jsCountdownScript",
countdownScript);
if (!cs.IsClientScriptBlockRegistered("jsCountdown"))
cs.RegisterClientScriptBlock(
GetType(),
"jsCountdown",
jsCountdown);
protected void Page_Load(object sender, EventArgs e)
Can anyone help me with where I need to implement my code to get the List Item to be created when the Web Part properties are set?
Thanks in advance.
Rick Lister
-=Stylus=-Hi,
Please refer below link regarding web part custom properties,
I think you need to write code under ApplyChanges() Method.I am not sure. Just try it once.
http://sharepointkitchen.blogspot.in/2014/10/custom-web-part-properties-approach-2.html
Don't forget to mark it as an Answer if it resolves your problem or Vote Me if it useful.
Mahesh -
Tab Order under Control Properties - Display Tab not working
At present I'm trying to order a couple of Input-Fields and Checkboxes for the Tab-Key. Therefor I tried to use the "Tab Order" Property in the Control Properties - Display Tab - Section: Layout - Tab Order.
In the SAP Library this property is described that way:
When user tabs through the controls of the component in runtime, the number indicating what place this control has in the tab order. Note that -1 removes the control from the tab order entirely and 0 indicates that it is highlighted according to its appearance in the component
Source: [Help.sap|http://help.sap.com/saphelp_nw70/helpdata/en/42/c2ba7f545e3116e10000000a1553f7/frameset.htm]
The problem now is that VC is completely ignoring this property and just using the tab order in the way the (Input-) fields where created.
At present I don't see any opportunity to give my "Form view" any logical tab order.
Is there any workaround? Is it a bug? Is there something I'm doing wrong?
Thanks for your help in advance.Hi,
It seems that this tab order works only for few of the controls like pushbutton, radio button, checkbox, toggle button...
i too tried this in my model but it was not working for the input fields of other types.
regarding -1 -2 ... these values work normally as per their values here -1 -2 order functions just like 2 1.
hope this helps you.
Regards,
Rk. -
Edit webpart properties using sharepoint designer workflow
Hi Guys,
I am not sure if there is any way to Edit properties of Excel Web Access WebPart using SharePoint Designer Workflow. I want to change workbook source of a web part on specific date.
I don't have environment to write custom code.
Thanks, NileshHi,
Per my knowledge, we can't achieve your requirement using SharePoint Designer Workflow.
We have to use custom code to achieve it. The following articles for your reference:
How to: Work with Web Parts on a Page Using JavaScript
http://msdn.microsoft.com/en-us/library/office/hh185010(v=office.14).aspx
Programmatically Update the SharePoint Web Part Properties on the List Forms
http://nikpatel.net/2010/11/04/programmatically-update-the-sharepoint-web-part-properties-on-site-pages/
ExcelWebRenderer class
http://msdn.microsoft.com/en-us/library/microsoft.office.excel.webui.excelwebrenderer(v=office.15).aspx
Best Regards
Dennis Guo
TechNet Community Support -
Ribbon and webpart properties disabled in publishing page Sharepoint 2013
Hello,
I have a problem with our sharepoint site 2013. I don't know how it came because it worked two weeks ago but when I go on a page and I select modify the page I cannot modify the webparts on the page. Before I had a little box on the top right and I could
choose the proprites of the wqebpart but now i have only this sign to reduce or open the webpart.
The button on the ribbon modify the webpart is disabled and it says that I have not the rights to modify it. But I am administrator...
Do you have a solution because it really disturb us in our work.
Thank you so much.
JoëlleHi,please find the below link that exactly discussion about the issue that your seeing in your environment.
http://expertsharepoint.blogspot.de/2014/08/open-with-explorer-is-disabled-in-for.html
Anil Avula[MCP,MCSE,MCSA,MCTS,MCITP,MCSM] See Me At: http://expertsharepoint.blogspot.de/ -
How to create a tool pane for apps in SharePoint using SharePoint hosted app model 2013..I mean i m looking for something like webpart propeties to be given to the user for selecting desired content.Can someone provide help code for this functionality
Hi,
According to your description, when users select several items in a library and click a button, you want to get related data from these items/files and then perform
other operations.
Yes, the “Custom Action in Ribbon” solution would be a good choice for you cause what you need is only clicking a button after selected items in a list view page.
With JavaScript Client Object Model, we can get data of the selected items using JavaScript, then add the JavaScript code into the custom action to make it to be triggered
when clicking the button.
I would suggest you take a look at the two links below about how to work with custom ribbon button and JavaScript Client Object Model for a quick start:
https://patrickboom.wordpress.com/tag/client-object-model/
http://blogs.msdn.com/b/jfrost/archive/2009/11/08/how-to-display-a-sharepoint-dialog-from-ribbon-button-and-get-selected-item-context.aspx
Best regards
Patrick Liang
TechNet Community Support -
Order of the validation error for mandatory properties
Hi,
I have created mandatory Properties in KM Configuration.I have configured in such a way that the properties are shown while uploading a file.Now when I upload a file without filling the properties it shows the validation error for the properties but it is not shown in the order of the properties mentioned in the property Groups.
Everytime the error is shown in a random order.
Please advise me whether I am missing something in the configuration.
Thanks in advance
Sowjanya.Hi,
is it possible, that someone inserted data with a different GC as parameter than your actual group currency is?
otherwise: I had the same problem, but I actually don't know the reason. I changed the validation rule:
before i had: VAL_YTD( write-offs cap. assets BS ) = VAL_YTD( write-offs PL)
now i have: ABS( VAL_YTD( write-offs cap. assets BS ) ) = ABS( VAL_YTD( write-offs PL) )
ABS = absolute value (no sign, only values).
You could also do it like that: ABS( VAL_YTD( write-offs cap. assets BS ) ) - ABS( VAL_YTD( write-offs PL) ) = 0
PS: To have the amount 0 in a validation rule is a restricted perspective. Never forget that!
Not only for the validation - it is always absolutely important to make sure which perspective you have choosen. Check the parameters, check the rules, the selections etc.
BR -
Retrieve Wiki WebPart ID Property through CSOM
I currently have a wiki page with content as well as several script editor web parts spaced throughout. I am attempting to get all content from the wiki page in order throught the SharePoint CSOM. When grabbing the WikiField content I can see where each
of the script editor web parts are placed because they have a DIV element with a GUID
<div class="ms-rtestate-read ms-rte-wpbox" contenteditable="false">
<div class="ms-rtestate-notify ms-rtestate-read 62f32861-7a85-489b-b92f-1784d7e758c9" id="div_62f32861-7a85-489b-b92f-1784d7e758c9" unselectable="on">
</div>
<div id="vid_62f32861-7a85-489b-b92f-1784d7e758c9" unselectable="on" style="display: none;">
</div>
</div>
The problem is that the GUID in the WikiField content is the web part id property while it seems that I can only retrieve the WebPartDefinition ID through CSOM, which is different. I need to find a way to match up the GUID in the WikiField content with the
GUID in the WebPartDefinition WebPart so that I can grab the content from the manager and place it in the correct spot on the wiki page. There doesn't seem to be a WebPartDefinition.WebPart.ID property in the SharePoint CSOM.
So far my code is:
Public Function GetWiki(ByVal pSPSite As String, ByVal pLibraryName As String, ByVal pItemId As Int32) As Boolean
Dim context As New ClientContext(pSPSite)
Dim WikiLibrary As List = context.Web.Lists.GetByTitle(pLibraryName)
Dim listItem As ListItem = WikiLibrary.GetItemById(pItemId)
Dim wikiPage As File = listItem.File
Try
context.Load(wikiPage)
context.Load(listItem)
context.ExecuteQuery()
Dim WikiContent As String = listItem("WikiField")
Dim wpm As LimitedWebPartManager = wikiPage.GetLimitedWebPartManager(PersonalizationScope.Shared)
context.Load(wpm.WebParts, Function(wps) wps.Include(Function(wp) wp.WebPart.Properties, Function(wp) wp.Id))
context.ExecuteQuery()
'Retrieve Script Web Parts added to Wiki Page
For Each wpd As WebPartDefinition In wpm.WebParts
Dim wpContent As String = wpd.WebPart.Properties("Content")
Dim wpTitle As String = wpd.WebPart.Properties("Title")
Next
Return True
Catch ex As Exception
Return False
End Try
End FunctionHi,
The Microsoft.SharePoint.Client.WebParts.WebPart class does not contain the ID property.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.webparts.webpart_members(v=office.15).aspx
We can use WebPartPages.asmx and GetWebPartProperties2 to get the WebPart GUID.
http://msdn.microsoft.com/en-us/library/websvcwebpartpages.webpartpageswebservice(v=office.15).aspx
Best Regards
Dennis Guo
TechNet Community Support -
Opening documents in Content Search Webpart
Hi,
I have configured Office Web app server with my SharePoint farm. It is working fine with document libraries. I have added the content search web part on home page. Office web app is not opening documents from CSWP. If i click in the document in CSWP, it
always prompts me to download the document.
Is this behavior is by design or i am missing some configuration in CSWP?
I have found article about same problem in Content Search Web Part.
http://jeroenvanree.wordpress.com/2012/10/18/sharepoint-2010-content-query-web-part-open-office-documents-in-office-web-app/
Same work around for CSWP in SharePoint 2013? Any help?I see it a default behavior
Try below as workaround
http://jeroenvanree.wordpress.com/2012/10/18/sharepoint-2010-content-query-web-part-open-office-documents-in-office-web-app/
First I added a couple of templates to get the File and Site Paths I needed to build the URL
ContentQueryMain.xsl
Template:
<xsl:template name=”OuterTemplate.StripLast”>
<xsl:param name=”pText”/>
<xsl:param name=”pDelim” select=”‘/’”/>
<xsl:if test=”contains($pText, $pDelim)”>
<xsl:value-of select=”substring-before($pText, $pDelim)”/>
<xsl:if test=”contains(substring-after($pText, $pDelim), $pDelim)”>
<xsl:value-of select=”$pDelim”/>
</xsl:if>
<xsl:call-template name=”OuterTemplate.StripLast”>
<xsl:with-param name=”pText” select=”substring-after($pText, $pDelim)”/>
<xsl:with-param name=”pDelim” select=”$pDelim”/>
</xsl:call-template>
</xsl:if>
</xsl:template>
This template gets the Site Path out of the FilePathRef value of the file
ItemStyle.xsl
Call the template
<xsl:variable name=”SitePath“>
<xsl:variable name=”p” select=”@Description“/>
<xsl:call-template name=”OuterTemplate.StripLast”>
<xsl:with-param name=”pText” select=”$p”/>
</xsl:call-template>
</xsl:variable>
In this case the Description field out of the content query webpart properties is used to fill the
FileRefPath
The next thing is to use this variable in the build of the string:
<a href=”/{$SitePath}/_layouts/WordViewer.aspx?id={$SafeLinkUrl}” title=”{@LinkToolTip}”>
<xsl:if test=”$ItemsHaveStreams = ‘True’”>
<xsl:attribute name=”onclick”>
<xsl:value-of select=”@OnClickForWebRendering”/>
</xsl:attribute>
</xsl:if>
<xsl:if test=”$ItemsHaveStreams != ‘True’ and @OpenInNewWindow = ‘True’”>
<xsl:attribute name=”onclick”>
<xsl:value-of disable-output-escaping=”yes” select=”$OnClickTargetAttribute”/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select=”$DisplayTitle”/>
</a>
If this helped you resolve your issue, please mark it Answered -
Issue in rendering CustomToolpart to select data source for custom webpart..
I have a custom webpart in which i have added a tool part.This toolpart should allow me to select any list in the sitecollection which would be displayed on the webpage on doing apply in the webpart properties.The dropdown list with all lists is coming fine.The
grid is diplaying as well.But in the toolpart,not in the webpart. I cant seem to segregate the two.There is also a textbox in the toolpart in which the entered text comes in the webpart.But the same approach is failing for the gridview.Please suggest
what to do.
Also,i am failing at making a separate category for the toolpart by specifying [category("List settings")]..Any suggestion as to what i'm doing wrong in that are welcome too.
Here is my webpart class and toolpart class.
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.Data;
using Microsoft.SharePoint.Utilities;
namespace BB.WorkSpaces.Common.WebParts.CustomList
[ToolboxItemAttribute(false)]
public class CustomList : Microsoft.SharePoint.WebPartPages.WebPart
[Browsable(false),
Category("List Settings"),
Description("Text Property")]
// Visual Studio might automatically update this path when you change the Visual Web Part project item.
private const string _ascxPath = @"~/_CONTROLTEMPLATES/BB.WorkSpaces.Common.WebParts/CustomList/CustomListUserControl.ascx";
public string ListName
get
return _listName;
set
_listName = value;
string _listName;
public string ListValue
get
return _listValue;
set
_listValue = value;
string _listValue;
public GridView Gv
get { return gv; }
set { gv = value; }
GridView gv;
protected override void Render(HtmlTextWriter writer)
base.Render(writer);
writer.Write(ListName);
writer.Write("<br />");
writer.Write(ListValue);
writer.Write("<br />");
writer.Write(Gv);
public override ToolPart[] GetToolParts()
ToolPart[] allToolParts = new ToolPart[3];
WebPartToolPart standardToolParts = new WebPartToolPart();
CustomPropertyToolPart customToolParts = new CustomPropertyToolPart();
allToolParts[0] = standardToolParts;
allToolParts[1] = customToolParts;
allToolParts[2] = new CustomToolPart();
return allToolParts;
public class CustomToolPart : Microsoft.SharePoint.WebPartPages.ToolPart
DropDownList ddl;
TextBox tb;
protected override void CreateChildControls()
ddl = new DropDownList();
ddl.ID = "ddl";
// Simply getting the lists of the current web, and displaying them in the dropdown-list.
SPListCollection lists = SPContext.Current.Web.Lists;
foreach (SPList list in lists)
ddl.Items.Add(list.Title);
tb = new TextBox();
tb.ID = "tb";
Controls.Add(ddl);
Controls.Add(tb);
base.CreateChildControls();
public override void ApplyChanges()
CustomList wp = (CustomList)this.ParentToolPane.SelectedWebPart;
wp.ListName = ddl.SelectedValue;
wp.ListValue = tb.Text;
SPSite site = SPContext.Current.Site;
SPWeb web = site.RootWeb;
SPList list = web.Lists[ddl.SelectedItem.Text];
//SPListItemCollection slist = list.GetItems();
GridView GV1 = new GridView();
DataTable dt = list.Items.GetDataTable();
GV1.DataSource = dt;
GV1.DataBind();
this.Controls.Add(GV1);Hi,
According to your post, my understanding is that you have an issue about the custom web part.
Per my knowledge, we should customize the EditorPart instead of the
ToolPart to bind the lists to the dropdown list.
There is a good article about customizing web part, you can refer to it.
http://www.concurrency.com/blog/create-a-custom-web-part-for-sharepoint-2010/
More reference:
http://www.enjoysharepoint.com/Articles/Details/show-all-list-in-dropdown-list-using-visual-web-part-20676.aspx
Thanks & Regards,
Jason
Jason Guo
TechNet Community Support -
We have three drop downs (ddlRotation, ddlOnCallType and ddlHospital) in our webpart. All values are being populated dynamically. One from list (ddlHospital) and other from tool part properties. For dropdown populated from list, we are storing values in
View State.
WebPart is working fine in development environment (single machine) while on production ( 1 front end, 1 index and 1 db server), drop down values disappear after post back. Below is the code.
protected void Page_Load(object sender, EventArgs e)
try
if (!Page.IsPostBack)
LoadData();
if (!string.IsNullOrEmpty(webPart._rotationDetail))
ddlRotation.Items.Add(new ListItem("All", "0"));
int i = 1;
string[] strRotationDetail = webPart._rotationDetail.Split(':');
foreach (string str in strRotationDetail)
ddlRotation.Items.Add(new ListItem(str, i.ToString()));
i++;
if (!string.IsNullOrEmpty(webPart._onCallTypes))
ddlOnCallType.Items.Add(new ListItem("All", "0"));
int j = 1;
string[] strOnCallTypes = webPart._onCallTypes.Split(':');
foreach (string str in strOnCallTypes)
ddlOnCallType.Items.Add(new ListItem(str, j.ToString()));
j++;
catch (Exception ex)
private void LoadData()
SPSecurity.RunWithElevatedPrivileges(delegate()
using (SPSite spSite = new SPSite("SITE_URL"))
using (SPWeb spWeb = spSite.OpenWeb())
SPList oList = spWeb.Lists[webPart.destListName];
SPListItemCollection setuplistItems = oList.Items;
if (setuplistItems != null && setuplistItems.Count > 0)
DataTable dtSetupData = setuplistItems.GetDataTable();
if (ViewState["SetupData"] != null)
ViewState.Remove("SetupData");
ViewState.Add("SetupData", dtSetupData);
else
ViewState.Add("SetupData", dtSetupData);
LoadHospitalCombo();
dateControl.SelectedDate = DateTime.Now;
else
// some error message
private void LoadHospitalCombo()
if (ViewState["SetupData"] != null)
DataTable dt = (DataTable)ViewState["SetupData"];
DataView dv = dt.DefaultView;
ddlHospital.Items.Clear();
ddlHospital.DataTextField = "TITLE";
ddlHospital.DataValueField = "TITLE";
ddlHospital.DataSource = dv.ToTable(true, "TITLE");
ddlHospital.DataBind();
ddlHospital.Items.Insert(0, "All");
Any help?
http://farhanfaiz.wordpress.comRunning your code in try/catch and doing nothing on exception, is not a good idea. Please try to put logging in your code as I believe your code is throwing exception. It's difficult to say seeing such a code what's wrong. Maybe the list doesn't exist or
exists with different name/title, or viewstate is disabled or webpart properties are not populated... there's so many possibilities. Also if possible refactor your code as shown below:
//Your Code, you are loading all items from database and then counting it
SPListItemCollection setuplistItems = oList.Items;
if (setuplistItems != null && setuplistItems.Count > 0)
//Refactored Code
if (oList.ItemCount > 0)
Thanks,
Sohel Rana
http://ranaictiu-technicalblog.blogspot.com -
Input schedule: Derive key for key range from Dimension member properties
Hey guys,
I'm facing the problem within a input layout. There are three keys in the row key range.
The first row key is filled by the members of a dimension. The second and third row
should be filled by the dependencies shown in the dimension members.
Example:
Dimension:
- Order number
Properties:
- Client (also implemented as standalone dimension where all required characteristics are maintaned)
- Costcenter (also implemented as standalone dimension where all required characteristics are maintaned)
Entries in dimension members of Ordern number:
Order number, Client, Costcenter:
1000, 10, 511
2000, 10, 533
3000, 12, 511
4000, 15, 588
Entries in dimension Members of Client:
10,11,12,13,14,15,16,17,18,19,20
Entries in dimension Members of Costcenter:
511,533,555,588
My row key range is defined as follows: Exp1: Order number, Exp2: Client, Exp3: Costcenter
For Planning purposes i need a input schedule that schows only the valid combinations shown above
in master data of order number. Is this possible or do I have to leverage script logic to use dependencies shown in master data for reporting oder planning purposes !
Cheers,
MoritzHi Moritz,
As Nilanjan said, this is not really possible with a basic EVDRE at the moment. Your best bet is probably to either build your own solution using EVEXP, EVGET, and EVSND, or to use an EVDRE based on only the Order # to get the values and an EVSND based on the Order # and the properties of the Order # in the AfterRange of the EVDRE.
I actually like the second option a lot better (EVDRE with EVSND in the AfterRange) because for larger queries the read performance should be better and it will be more maintainable in the long run.
Ethan
Maybe you are looking for
-
Syncing email folders to iPhone & iPad
I have a hotmail/outlook account. My inbox seems to sync just fine to my ipad and iphone, but for sone reason none of the folders that I've created over time will sync. This was never an issue until as of lately. All of my folders would sync, but all
-
Exception while calling the dotnet web service.
I have an Axis2-1.3 web client to a dotnet web service. The client makes rapid calls to the webservice. some times it works but often the call fails with the following exception. org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxIOException: Connectio
-
How do I delete old Bex queries not used within 13 months?
Hello all, I have a large number of Bex queries that are no longer used (3000 - three thousand). I'd like to delete any query that has not been used in 13 months. Can someone provide some guidance? Also, is there anyway to archive old reports? Thank
-
Support for EAP-TTLS-PAP (as used by Eduroam) in N...
When it will be available a solution to the lack of support for EAP-TTLS-PAP (as used by Eduroam) in Nokia N86 8MP throught a new firmware? To many years waiting... Must we go to another solution? Thx.
-
Cant partition my hard drive more than 10 GB
i have only the primary " C: " partition now and i have over 300 GB of free space on it when i try to make a new partition the max space i can get for it is only 10 GB , please help