| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 91041 | 2008-06-24 05:03:00 | ASP.NET DropDownList + DetailsView problem | somebody (208) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 681775 | 2008-06-24 05:03:00 | I have a simple ASP.NET page with a DetailsView, with DefaultMode set to "Insert" and editing/viewing/deleting disabled. I have several fields which I have converted into TemplateFields, for example: <asp:TemplateField HeaderText="custJoinDate" SortExpression="custJoinDate"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("custJoinDate") %>'></asp:TextBox> </EditItemTemplate> <InsertItemTemplate> <asp:Calendar ID="Calendar1" runat="server" ></asp:Calendar> </InsertItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" ></asp:Label> </ItemTemplate> </asp:TemplateField> Note that the ItemTemplate and EditItemTemplate are essentially redundant, as the user is not able to access those modes. I have some other code in Page_Load which sets the calendar control to today's date: Calendar joinDate = DetailsView1.FindControl("Calendar1") as Calendar; joinDate.SelectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); This all works as expected - the first time the user goes to the page, the calendar field is populated with today's date. That's fine. Once the user hits "Insert" which posts back the DetailsView form to be inserted into the db, the page which subsequently loads - with a blank DetailsView - has the Calendar field left unselected. I have another field which is a DropDownList, pulling data from the database, which has the same behaviour - it shows up on first load, but subsequent loads cause problems. I do not have any "isPostBack" checks on Page_Load, and I have tried other events like Page_PreRender, DetailsView1_Load, and so on, and it doesn't make a difference. This is a small problem, but it's bugging the living daylights out of me. Any ideas? |
somebody (208) | ||
| 681776 | 2008-06-24 09:09:00 | Problem now resolved. | somebody (208) | ||
| 1 | |||||