This is a migrated thread and some comments may be shown as answers.

Cannot Switch Edittemplate When Row Clicked

1 Answer 7 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Mohammad Hazem
Top achievements
Rank 1
Mohammad Hazem asked on 11 Sep 2013, 01:58 PM
<asp:UpdatePanel ID="uplstAddress" runat="server">
                                   <ContentTemplate>
                                       <ITG:ITG_ListView ID="lsvMainAddress" runat="server" OnItemCommand="lsvMainAddress_ItemCommand" OnPreRender="lsvMainAddress_PreRender"
                                            ItemPlaceholderID   ="ContactAddressContainer" DataKeyNames="ADDRESS_ID,ISPRIMARY" AllowPaging="True" OnPageIndexChanged="lsvMainAddress_PageIndexChanged" OnPageSizeChanged="lsvMainAddress_PageSizeChanged" OnItemDataBound="lsvMainAddress_ItemDataBound"
                                           PageSize="1" meta:resourcekey="lsvMainAddress1">
 
                                           <LayoutTemplate>
                                               <fieldset>
                                                   <legend>
                                                       <asp:Label ID="lblContactAddTitle" runat="server" Text="Contact Addresses" meta:resourcekey="TitleAddress"></asp:Label>
                                                   </legend>
                                                   <asp:PlaceHolder ID="ContactAddressContainer" runat="server" EnableViewState="false"></asp:PlaceHolder>
                                                   <div style="clear: both"></div>
 
                                                   <uc3:ucCustomPaging runat="server" ID="oucCustomPagingAddress" />
                                               </fieldset>
                                           </LayoutTemplate>
 
                                           <ItemTemplate>
                                               <fieldset ondblclick='row_doubleclick("<%#Container.DisplayIndex %>")'>
                                                   <legend>
                                                   </legend>
                                                   <table>
                                                        <tr>
                                                           <td colspan="2">
                                                               <asp:CheckBox ID="chkDetailsAddressEdit" runat="server" />
                                                           </td>
                                                            <asp:HiddenField ID="hfAddressEdit" runat="server" Value='<%# Eval("ADDRESS_ID")%>' />
                                                       </tr>
                                                       <tr>
                                                           <td style="width: 100px;">
                                                               <asp:Label ID="lblISPrimaryAddress" runat="server" Text="Primary Address" meta:resourcekey="lblPrimaryDResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
                                                           <td>                   
                                                               <asp:RadioButton ID="rdPrimaryAddressEdit" runat="server" OnCheckedChanged="rdPrimaryAddressEdit_CheckedChanged" CausesValidation="false" AutoPostBack="true"/>
                                                               <asp:HiddenField ID="hfEditPrimary" runat="server" Value='<%# Eval("ISPRIMARY")%>' />
                                                           </td>
                                                       </tr>
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblCountryView" runat="server" Text="Country" meta:resourcekey="lblCOUNTRY_IDResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("LangCountryDesc")%>
                                                           </td>
                                                       </tr>
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblCityView" runat="server" Text="City" meta:resourcekey="lblCITYResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("CITY")%>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblStreetView" runat="server" Text="Street" meta:resourcekey="lblSTREETResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("STREET")%>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblStatusView" runat="server" Text="Status" meta:resourcekey="lblSTATUS_IDResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("LangStatusDesc")%>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblStateView" runat="server" Text="State" meta:resourcekey="lblSTATEResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("STATE")%>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblZipCodeView" runat="server" Text="Zip Code" meta:resourcekey="lblZIPCODEResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("ZIPCODE")%>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblPhoneView" runat="server" Text="Phone No." meta:resourcekey="lblPHONEResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("PHONE")%>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblMobileView" runat="server" Text="Mobile No." meta:resourcekey="lblMOBILEResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("MOBILE")%>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblFaxView" runat="server" Text="Fax No." meta:resourcekey="lblFAXResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("FAX")%>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblMailView" runat="server" Text="E-Mail" meta:resourcekey="lblEMAILResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("EMAIL")%>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblWebSiteView" runat="server" Text="Web Site" meta:resourcekey="lblWEBSITEResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <%#Eval("WEBSITE")%>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblCreationDateView" runat="server" Text="Creation Date" meta:resourcekey="lblCreationdateVeiwResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
                                                           <td>
                                                               <%#Eval("CREATIONDATE", "{0:dd/MM/yyyy}")%>
                                                           </td>
                                                       </tr>
 
                                                   </table>
 
                                               </fieldset>
                                           </ItemTemplate>
 
                                           <EditItemTemplate>
 
                                               <fieldset>
                                                   <legend>
                                                       <asp:Label ID="lbltest" runat="server" Text="Edittable Template"></asp:Label>
                                                   </legend>
 
                                                   <table>
 
                                                       <tr>
                                                           <td style="width: 100px;">
                                                               <asp:Label ID="lblCountryViewEditTemplate" runat="server" Text="Country" meta:resourcekey="lblCOUNTRY_IDResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbCountryEditTemplate" Text='<%#Bind("LangCountryDesc")%>' runat="server"></ITG:ITG_TextBox>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblCityViewEditTemplate" runat="server" Text="City" meta:resourcekey="lblCITYResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbCityEditTemplate" Text='<%#Bind("CITY")%>' runat="server"></ITG:ITG_TextBox>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblStreetViewEditTemplate" runat="server" Text="Street" meta:resourcekey="lblSTREETResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbStreetEditTemplate" Text='<%#Bind("STREET")%>' runat="server"></ITG:ITG_TextBox>
 
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblStatusViewEditTemplate" runat="server" Text="Status" meta:resourcekey="lblSTATUS_IDResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbStatusEditTemplate" Text='<%#Bind("LangStatusDesc")%>' runat="server"></ITG:ITG_TextBox>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblStateViewEditTemplate" runat="server" Text="State" meta:resourcekey="lblSTATEResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbStateEditTemplate" Text='<%#Bind("STATE")%>' runat="server"></ITG:ITG_TextBox>
 
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblZipCodeViewEditTemplate" runat="server" Text="Zip Code" meta:resourcekey="lblZIPCODEResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbZIPCODEditTemplateEdit" Text='<%#Bind("ZIPCODE")%>' runat="server"></ITG:ITG_TextBox>
 
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblPhoneViewEditTemplate" runat="server" Text="Phone No." meta:resourcekey="lblPHONEResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbPhoneEditTemplateEdit" Text='<%#Bind("PHONE")%>' runat="server"></ITG:ITG_TextBox>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblMobileViewEditTemplate" runat="server" Text="Mobile No." meta:resourcekey="lblMOBILEResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbMobileEditTemplateEdit" Text='<%#Bind("MOBILE")%>' runat="server"></ITG:ITG_TextBox>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblFaxViewEditTemplate" runat="server" Text="Fax No." meta:resourcekey="lblFAXResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbFaxEditTemplateEdit" Text='<%#Bind("FAX")%>' runat="server"></ITG:ITG_TextBox>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblMailViewEditTemplate" runat="server" Text="E-Mail" meta:resourcekey="lblEMAILResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbEmailEditTemplateEdit" Text='<%#Bind("EMAIL")%>' runat="server"></ITG:ITG_TextBox>
                                                           </td>
                                                       </tr>
 
                                                       <tr>
                                                           <td>
                                                               <asp:Label ID="lblWebSiteViewEditTemplate" runat="server" Text="Web Site" meta:resourcekey="lblWEBSITEResource1"></asp:Label>
                                                           </td>
                                                           <td class="DoubleDot">:
                                                           </td>
 
                                                           <td>
                                                               <ITG:ITG_TextBox ID="tbWebSiteEditTemplateEdit" Text='<%#Bind("WEBSITE")%>' runat="server"></ITG:ITG_TextBox>
                                                           </td>
                                                       </tr>
 
                                                   </table>
 
                                               </fieldset>
 
                                           </EditItemTemplate>
 
                                       </ITG:ITG_ListView>
                                   </ContentTemplate>
                               </asp:UpdatePanel>

Java Script Function
   <telerik:RadCodeBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function row_doubleclick(index) {
                //set item into edit mode
                $find("<%=lsvMainAddress.ClientID %>").editItem(index);
                 
            }
            </script>
    </telerik:RadCodeBlock>
Dears, Telerik Team

When i Clicked On ListView Item ; Javascript  function "row_doubleclick" fired.

but cannot Awitch To EditMode , and if doucleclick again the Message "Inner Excpetion" Show as:

"Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request."

Please, Help ........!

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 16 Sep 2013, 01:27 PM
Hello Mohammad,

I have tested your markup with dummy data and double clicking within the row is opening EditItemTemplate as expected on my side.

Please note that custom controls (even those that inherits our RadCotrols) are not supported and should be handled entirely on your side. 

Nevertheless, I have prepared for you a sample project using RadListView and your markup that works on my side. 

Additionally, note that "failed to load Viewstate" exception could be caused by dynamically adding controls in Page_Load method. For more information on that matter, please have a look at the following articles and forum threads regarding the exception you are receiving:

Hope that helps.

 

Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ListView
Asked by
Mohammad Hazem
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or