Hi
I'm using a WebDropDown with an ItemTemplate that renders multiple columns from an underlying datasource, just like shown in the video from craigshoemaker. I've set the AutoPostback property to true. Everything loads well when I run the page. When I select a value the page does a postback (as desired).But now all the items from the WebDropDown are empty, however the template-layout is still applied and the Value and Text properties are still filled up.It seems that the DataItems get null, because they're not being saved in the ViewState?
Is this normal behavior? The only workaround I can find is to DataBind the control on every postback.
I've attached a sample project (VB.NET and version 9.1.20091.2040)
Hey David,
The links appear because probably CSS styles are not loaded correctly. do you have an ig_res folder somewhere? You can set the StyleSetName and StyleSetPath properties to define where is the location for all styling. In the default styling links are not displayed because there is specific css that removes all of this default "decoration".
Thanks,
Angel
When I remove the ItemTemplate the items in the dropdown list have hyperlinks on them which looks terrible. That is why I had to put in an ItemTemplate. Do you know how to get rid of the hyperlinks any other way?
Also, why would my DataBind now be working? It sounds like you have had success with it. You can see the code that is in the Page_Load method. There is nothing more than that. It is a simple test app to show this behaviour. My real web app has the same issues but it is more complex.
Hi,
You are already binding the Text property by specifying the TextField mapping. So if you just remove the itemTemplate markup, i think it will be all ok.
Hope it helps,
if (!IsPostBack) { DataTable dt = new DataTable(); dt.Columns.Add("ProvinceName"); dt.Rows.Add("British Columbia"); dt.Rows.Add("Alberta"); dt.Rows.Add("Saskatchewan"); dt.Rows.Add("Manitoba"); dt.Rows.Add("Ontario"); dt.Rows.Add("Quebec"); dt.Rows.Add("New Brunswick"); dt.Rows.Add("Nova Scotia"); dt.Rows.Add("Newfoundland/Labrador"); dt.Rows.Add("Prince Edward Island"); dt.Rows.Add("Nunavut"); dt.Rows.Add("Yukon"); dt.Rows.Add("Northwest Territories");
webDropDownProvince0.DataSource = dt; webDropDownProvince0.ValueField = "ProvinceName"; webDropDownProvince0.TextField = "ProvinceName"; } webDropDownProvince0.DataBind();
I do call DataBind on each PostBack and I still have the same result.
What do you mean by bind the Text property?