Showing posts with label setting. Show all posts
Showing posts with label setting. Show all posts

Wednesday, March 21, 2012

Define itemTemplate for Reorderlist at runtime

Hi,

I am able to get the reorderlist control to work my supplying a datasource and writing the markup for the itemTemplate.

How do i go about setting the itemTemplate at runtime depending on the datasource?

I tried programatically creating ReorderListItems, and collections but nothing got rendered.

I see that the ReorderList has an itemTemplate property, will this help?

OK. I have figured it out how to do it by creating a class that implements the ITemplate interface.

The problem i have now is i am using the reorderlist control within the accordian control.

For example i have a menu with 3 selections. This is controlled by the accordian.

Within the each accordian pane, i create a reorderlist, therefore there are 3 reorderlists, one within each accordian pane. This works fine, and i am able to reorder the items in the list. However, it seems that when i try to move items in the 2nd/3rd pane, they all disappear into the 1st pane. Is this because even though it looks like the accordian is shrinking and expanding, the actual working area for the reorder list is already defined, hence when pane 1 is minimised with pane 2 open, pane 2 reorderlist is actually already ontop of pane 1 reorder list??

I hope the above makes sense.

Default value in child CascadingDropDown

I'm using the standard technique for setting the default option in the Web service: result.Add(newCascadingDropDownNameValue(name, code, BLOCKED EXPRESSION

(expression is true only for the default option)

This technique ony works for the parent list, and doesn't do anything for the child list. In other words, when the selection on the parent list changes, and the child list gets populated via its Web service, setting the default option via the above technique doesn't actually do anything (the first option of the child element is always selected by default). What am I doing wrong?

Hi Tomers,

My understanding of your case is that you want to set a default value for DropDownList ,which is associated with a CascadingDropDown.

As far as I know, the returned value will add to it's child list instead of parent list. Here is the code section in CascadingDropDownNameValue.cs.

public CascadingDropDownNameValue(string name, string value, bool defaultValue)
{
this.name = name;
this.value = value;
this.isDefaultValue = defaultValue;
}

I have made a sample and it works fine on my local machine. Please see my sample which is using oledb:

[WebMethod]public CascadingDropDownNameValue[] GetCities(string knownCategoryValues,string category) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);int stateID;if (!kv.ContainsKey("State") || !Int32.TryParse(kv["State"],out stateID)) {return null; } List myList =new List(); strSql ="SELECT * FROM tb_City WHERE StateID=" + stateID.ToString(); GetDr(strSql);while (myReader.Read()) {if (myReader["CityName"].ToString() =="Shanghai") { myList.Add(new CascadingDropDownNameValue(myReader["CityName"].ToString(), myReader["CityID"].ToString(),true)); }else { myList.Add(new CascadingDropDownNameValue(myReader["CityName"].ToString(), myReader["CityID"].ToString(),false)); } } myReader.Close();return myList.ToArray(); }

In your case, I think you should check your code and debug it step-by-step if necessary.

Best Regards,

Jonathan