KRob
KRob

Reputation: 389

How to set a default template in a ListView control

I have a ListView control with an ItemTemplate, and an EditItemTemplate. By default, the ItemTemplate is rendered; how can I change that? More clearly, on Page_Load, I would like my EditItemTemplate to be the selected template.

<asp:ListView ID="lvExample" runat="server" SelectMethod="GetStuff" UpdateMethod="UpdateStuff">
    <EditItemTemplate>
      ...
    </EditItemTemplate>

    <EditItemTemplate>
      ...
    </EditItemTemplate>
 </asp:ListView>

Upvotes: 1

Views: 593

Answers (1)

Odeyinka Olubunmi
Odeyinka Olubunmi

Reputation: 857

You can use this approach. (1) Write your Edit logic/Edit Template in your inside you item template. (2) Then you can put your ItemTemplate content into another template.

since the default load template is ItemTemplate you get your edit template load first since the content of your itemteplate is your edit template

Upvotes: 1

Related Questions