I've created a custom dropdown datatype control and have implemented it into the content section ok. The selected values are being successfully saved and then subsequently read back out in the Content section. Using the same conrol in the Members secton, the Selected values are being lost when you click save.
static readonly string XmlFileLocation = ConfigurationManager.AppSettings["CategoryDropdown"];
private readonly string _xmlfile = HttpContext.Current.Server.MapPath(XmlFileLocation);
public string UmbracoValue;
public object value
{
get
{
return UmbracoValue;
}
set
{
UmbracoValue = value.ToString();
}
}
protected void Page_Init(object sender, EventArgs e)
{
//LoadData();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadData();
string[] items = new string[1];
items = value.ToString().Split(',');
foreach (ListItem listItem in cblCategory.Items)
{
foreach (var item in items)
{
if (listItem.Value == item)
{
listItem.Selected = true;
}
}
}
var checkboxItems = cblCategory.Items
.Cast<ListItem>()
.OrderBy(i => i.Text)
.ToArray();
cblCategory.Items.Clear();
cblCategory.Items.AddRange(checkboxItems);
}
else
{
string items = string.Empty;
// At this point I have the correct items in the cblCategory list, but the Selected state has been lost. This works ok in the Content section, but not the Member section.
foreach (ListItem item in cblCategory.Items)
{
if (item.Selected)
{
items += item.Value + ",";
}
}
if (items.Length > 0)
{
items = items.TrimEnd(',');
}
UmbracoValue = items;
}
}
//Loading the data from xml file
protected void LoadData()
{
var ds = new DataSet();
//reading xml file and loading listview.
ds.ReadXml(_xmlfile);
cblCategory.DataSource = ds.Tables[0];
cblCategory.DataTextField = "Name";
cblCategory.DataValueField = "Name";
cblCategory.DataBind();
}
Custom dropdown in Members section
I've created a custom dropdown datatype control and have implemented it into the content section ok. The selected values are being successfully saved and then subsequently read back out in the Content section. Using the same conrol in the Members secton, the Selected values are being lost when you click save.
is working on a reply...