mubChoroTor
New Member
All, <BR><BR>I have been asking about this in a number of forums to no avail. I didn't think it was that big a deal, but I'm going to try one more time. Here's what it boils down to. If I define a dropdown list as an <asp:dropdownlist...> and save it as an ascx file, then add it to a .aspx page as a user control: it is registered<%@ Register TagPrefix="UserControl"...%> and referenced between form tags <UserControl:MonthList id= "MonthList" runat = "Server"/> the drop down displays just fine. I tried the same thing (in this case I am just displaying a list of months to pick a date ) but instead of setting up the dropdown list on the ascx page using <asp:dropdownlist...> I retrieve the list of months from and XML file and, using DataBind, I bind that list to an <asp:dropdownlist...> on the same page. I then Register and display it as a user control on an aspx page, the same as I did in the first case. The difference is that if I submit the page to itself - with something other than the default month selected, when the page is posted back, the second user control (the one that was pulled from an XML file ) displays the default month, while the control that was defined as a 'hardcoded' asp:dropdown remembers the selected date. In other words the XML based control is not persisted. Make any sense to anybody?<BR><BR>Thanks, Daveare you binding the XML to the DropDownList only if not IsPostBack?I am creating the drop down like this:<BR> <BR><%@ Import Namespace= "System.Data" %><BR><script language="c#" runat ="server"><BR><BR>protected void Page_Load(Object Sender, EventArgs e){<BR> // Get the month list from an XML file<BR> DataTable objTable;<BR> DataSet objDataset = new DataSet( );<BR> objDataset.ReadXml(Server.MapPath("../xml/MonthList.xml" ));<BR> MonthList.DataSource = objDataset;<BR> MonthList.DataTextField="monthname";<BR> MonthList.DataValueField="monnumber";<BR> MonthList.DataBind( );<BR>}<BR></script><BR><asp
ropDownList id ="MonthList" runat = "server" /><BR><BR>Add to the aspx page like this:<BR><%@ Register TagPrefix="UserControl" TagName="setMonth" src=http://aspmessageboard.com/archive/index.php/"../calendar/setMonth.ascx" %><BR><BR><form runat ="server"><BR><table><tr><td colspan="2"><BR> <UserControl:setMonth id= "setMonth" runat = "Server"/> </td></tr></table></form><BR><BR>Any ideas? Thanks, Dave<BR><BR>
