Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:55:31+00:00 2026-06-13T03:55:31+00:00

I use this http://blogs.msdn.com/b/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx article as example for dynamic loading templates(from .ascx files). this

  • 0

I use this http://blogs.msdn.com/b/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx article as example for dynamic loading templates(from .ascx files).

this is author code:

     protected void Page_Load(object sender, EventArgs e)
    {

        ListView1.LayoutCreated += new EventHandler(ListView1_LayoutCreated);
        ListView1.LayoutTemplate = LoadTemplate("LayoutTemplate.ascx");
        ListView1.ItemTemplate = LoadTemplate("ItemTemplate.ascx");
    }

    void ListView1_LayoutCreated(object sender, EventArgs e)
    {
        //remove the layout template
        ListView1.Controls.RemoveAt(0);

        //recreate it
        Control newLayoutContainer = new Control();
        ListView1.LayoutTemplate.InstantiateIn(newLayoutContainer);
        var userControl = newLayoutContainer.Controls[0];
        userControl.ID = "MyLayout";
        ListView1.Controls.Add(newLayoutContainer);
    }

it gives error:

An ItemTemplate must be defined on ListView ‘ListView1’.

after postback.

What’s wrong? Should I create ListView every time I postback ( http://forums.asp.net/p/1305569/2558209.aspx )?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:55:33+00:00Added an answer on June 13, 2026 at 3:55 am

    To solve your problem do the following :

    <script runat="server">
    
       protected void ListView_Init(object sender, EventArgs e)
        {
    
             ListView1.ItemTemplate = LoadTemplate("ItemTemplate2.ascx");
    
        }
    
    </script>
    
    <asp:ListView ....   OnInit="ListView_Init">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following T4 template ( http://blogs.msdn.com/b/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx ) to pre-compile my Entity Framework
So, I'm attempting to use this: http://blogs.msdn.com/b/priozersk/archive/2010/09/17/customizing-picker-box-dialog.aspx However, I just want a normal pickerboxdialog
From this article http://blogs.msdn.com/b/ericlippert/archive/2010/04/08/precision-and-accuracy-of-datetime.aspx : Now, the question how much time has elapsed from
Following the example in this article: http://blogs.msdn.com/b/yaohuang1/archive/2012/05/21/asp-net-web-api-generating-a-web-api-help-page-using-apiexplorer.aspx I've set up everything to provide documentation
We are thinking to use the newly released EF 4.3.x http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-released.aspx does anybody know
I am using the following sample at http://blogs.msdn.com/dwayneneed/archive/2007/10/05/blurry-bitmaps.aspx within VB.NET. The code is shown
I'm trying to use http://blogs.msdn.com/b/cdndevs/archive/2012/01/23/javascript-and-css-minifying-bundling-with-the-microsoft-web-optimization-nuget-package.aspx To minify and bundle my css and js files
I created a simple WCF web service(following this tutorial: http://blogs.msdn.com/b/ericwhite/archive/2010/05/11/getting-started-building-a-wcf-web-service.aspx ), because I don't
I've been using http://blogs.msdn.com/b/haoxu/archive/2008/12/02/wwsapi-to-wcf-interop-nettcpbinding-with-transport-security.aspx as a guidelines on how to implement a secure connection
I've read in several place, include here http://blogs.msdn.com/b/jaimer/archive/2010/04/30/windows-phone-capabilities-security-model.aspx that if a Windows Phone app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.