Sunday, March 11, 2012

Dropdown List Issue

Since UpatePanel will bypass certain events normally associated with PostBack, there's a good chance that whatever event you're using to repopulate the original DDL items (via the dataset) is not being invoked. Can you reproduce a simple sample of this behavior and post the code if you can't figure it out?

I'm not using any events to populate the controls. I'm using business objects and binding the controls to the objects.

Do I need to manually bind these controls at runtime?


No. It should work fine. Not sure what's happening in your case. Again, without the code, I really can't speculate on what's going on.

Fair enough. Here is the code for the panel. Remember - no server side code is being used here.

<atlas:UpdatePanelID="p1"runat="server"EnableViewState="true"><ContentTemplate><divid="addhours"><aname="content_start"id="content_start"></a><fieldset><h2class="none">

Log your hours

</h2><legend>Log your hours</legend><asp:LabelID="lblWeekEnding"runat="server"Text="Week Ending:"></asp:Label>

Day

<asp:TextBoxID="WeekEnding2"runat="server"Columns="12"ValidationGroup="newEntry"></asp:TextBox><ahref="javascript:OpenPopupPage('Calendar.aspx','<%= WeekEnding2.ClientID %>','<%= Page.IsPostBack %>');"><imgsrc="images/icon-calendar.gif"border="0"align="absBottom"width="24"height="16"></a><asp:CompareValidatorid="CompletionDateCompareValidator"runat="server"Display="Dynamic"ErrorMessage="Date format is incorrect."ControlToValidate="WeekEnding2"Operator="DataTypeCheck"Type="Date"></asp:CompareValidator>

Project

<br/><asp:DropDownListID="ProjectList"runat="server"AutoPostBack="True"DataSourceID="Projects"DataTextField="Project"DataValueField="ProjectID"Font-Size="Smaller"/><asp:ObjectDataSourceID="Projects"runat="server"OldValuesParameterFormatString="original_{0}"SelectMethod="GetData"TypeName="wpsTimeEntryTableAdapters.DepartmentProjectsTableAdapter"><SelectParameters><asp:QueryStringParameterName="DEPARTMENTID"QueryStringField="DepartmentID"Type="Decimal"/></SelectParameters></asp:ObjectDataSource><asp:RequiredFieldValidatorID="RequiredFieldValidator2"runat="server"ControlToValidate="ProjectList"ErrorMessage="Project is a required value."Display="Dynamic"ValidationGroup="newEntry"></asp:RequiredFieldValidator>

Task

<br/><asp:DropDownListID="TaskList"runat="server"DataSourceID="Tasks"DataTextField="Task"DataValueField="TaskID"Font-Size="Smaller"/><asp:ObjectDataSourceID="Tasks"runat="server"OldValuesParameterFormatString="original_{0}"SelectMethod="GetData"TypeName="wpsTimeEntryTableAdapters.ProjectTasksTableAdapter"><SelectParameters><asp:ControlParameterControlID="ProjectList"Name="ProjectID"PropertyName="SelectedValue"Type="Decimal"/></SelectParameters></asp:ObjectDataSource></ContentTemplate></atlas:UpdatePanel>

Solved...

Here is the issue...

When an error is thrown on the the page, the dropdowns break. There was a compare validator that was choking. As soon as I removed it - problem solved.


Also - it seemed to not like the query string variable for the object datasource. I changed it to a session variable, and it worked fine.
Good to know. I guess it's rather tricky finding out the differences between a traditional postback versus the new client-callback used by AJAX/Atlas.

No comments:

Post a Comment