Hi. I have a rad rotator which shows some images and when the user click the image it shows the detail in a form view. It all appears to work however when I click the edit button the change event is fired but the form does not change into edit mode? The code is in a usercontrol. I'm sure I'm doing something really stupid, but cant see what :-(
Code behind, data is being bound in code behind using entity model;
<asp:FormView ID="frmDetail" runat="server" DataKeyNames="C_n_Id" OnItemUpdated="FormView_ItemUpdated" OnItemCommand="FormView_ItemCommand" DefaultMode="ReadOnly"> <ItemTemplate> <table style="padding:10px;"> <tbody style="vertical-align: top;"> <tr> <td width="80px"> <img src='<%# HttpUtility.UrlDecode(String.Format("{0}/_N{1}_small.png", HttpUtility.UrlEncode(Eval("C_s_ImageUrl").ToString()), Eval("C_n_Id"))) %>' width="64px" height="64px" class="RotatorImage" /> </td> <td> <asp:Label ID="lblDescription" runat="server" Text='<%# Bind("C_s_Description") %>' EnableTheming="true" /> </td> </tr> </tbody> </table> <br /> <b>Name:</b> <asp:Label ID="ProductNameLabel" runat="server" Text='<%# Bind("C_s_Name") %>' EnableTheming="true" /><br /> <b>Description:</b> <br /> <asp:Button ID="EditButton" Text="Edit" CommandName="Edit" runat="server" /> <asp:Button ID="Button1" Text="Insert" CommandName="Insert" runat="server" /> </ItemTemplate> <EditItemTemplate> <asp:Label runat="server" ID="lblTest" Text="Edit" /> <asp:TextBox ID="lblDescription2" runat="server" Text='<%# Bind("C_s_Description") %>' /> </EditItemTemplate> <InsertItemTemplate> <asp:Label runat="server" ID="lblTest" Text="Insert" /> </InsertItemTemplate> </asp:FormView>Code behind, data is being bound in code behind using entity model;
private Int64 LastID { get { return Convert.ToInt64(ViewState["LastID"]); } set { ViewState["LastID"] = value; } } protected void FormView_ItemUpdated(Object sender, FormViewUpdatedEventArgs e) { this.frmDetail.DataBind(); } protected void FormView_ItemCommand(object sender, FormViewCommandEventArgs e) { switch (e.CommandName) { case "Edit": this.frmDetail.ChangeMode(FormViewMode.Edit); break; } } protected void Page_Load(object sender, EventArgs e) { this.RebindRotator(); } private void RebindRotator() { thumbRotator.DataSource = DbContext.tblAccountNotifications.OrderBy(t=>t.C_s_Name); thumbRotator.DataBind(); } protected void BindForm() { this.frmDetail.DataSource = DbContext.tblAccountNotifications.Where(t => t.C_n_Id == this.LastID); this.frmDetail.DataBind(); } protected void GetSubscription(object sender, RadRotatorEventArgs e) { RadRotator rotator = sender as RadRotator; rotator.InitialItemIndex = e.Item.Index;// Persist the index this.LastID = Convert.ToInt64(((Label)e.Item.FindControl("lblId")).Text); this.BindForm(); }