November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Depends on how your code looks, but something like this:
public class PropertyWeekNumberDropDownControl : PropertySelectControlBase { protected override void SetupEditControls() { this.SetupDropDownList(); } private void SetupDropDownList() { this.EditControl.DataSource = GetWeekNumbers; if (this.WeekNumberDropDown.Value != null) { this.EditControl.SelectedValue = this.WeekNumberDropDown.Value as string; } this.EditControl.DataBind(); } public PropertyWeekNumberDropDown WeekNumberDropDown { get { return PropertyData as PropertyWeekNumberDropDown; } } }
This should save your value:
public override void ApplyEditChanges() { if (!String.IsNullOrEmpty(yourControl.SelectedValue)) { SetValue(yourControl.SelectedItem.Value); } }
And then to set it you need to go through your options and then check if its equal the current value:
foreach (var val in yourListOfOptions) { ListItem li = new ListItem(val, yourListOfOptions[val]); li.Selected = currentPropertyValue == yourListOfOptions[val]; yourControl.Items.Add(li); }
Something like that should do it I think
That did the trick. I was uncertain how it would assume the Get would belong to the page being edited but with a function name that revealing I see the connection. Thanks guys!
If someone might read this one still I've got another question. Is it possible to reach a dynamic property in the code for the custom property? I need to get the value of one to fill the dropdown. I usually just use CurrentPage["MyProperty"] but that won't work in this case.
So, I've created my first ever custom property - a dynamically filled DropDownList. Works great until I go back and edit an already saved page because it doesn't remember what my choice was. I'm sure there is some function I need to call to do this, I just don't know which one it is. Care to help me out? How do I set the selected value to the saved value from the last edit?