headertemplate asp:repeater的问题

时间:2011-06-01 12:18:46

标签: asp.net

嗨,伙计们请有人请asist ..我的代码如下:

图像按钮单击事件不会被触发但是只要我从标题模板中取出该事件就会被触发..请帮助我解决此问题!

谢谢!

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ResultsControl.ascx.cs"
Inherits="POS.Web.Campaign.Controls.ResultsControl" %>

    

    <div id="divResultsMain">
        <br />
        <asp:Repeater ID="repeaterCampaignList" runat="server" >
            <HeaderTemplate>
                <table cellspacing="0" cellpadding="0">
                    <tr class="repeaterAlternatingItem">
                        <th>
                            <asp:ImageButton ID="campNameAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                Height="20px" Width="20" OnClick="campNameAsc_Click" />
                            <asp:ImageButton ID="campNameDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                Height="20px" Width="20" OnClick="campNameDesc_Click" CausesValidation="False" />Campaign
                            Name
                        </th>
                        <th>
                            <asp:ImageButton ID="campIDAsc" runat="server" ImageUrl="~/images/up-arrow.jpg" Height="20px"
                                Width="20" OnClick="campIDAsc_Click" />
                            <asp:ImageButton ID="campIDDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                Height="20px" Width="20" OnClick="campIDDesc_Click" />Campaign ID
                        </th>
                        <th>
                            <asp:ImageButton ID="campTypeAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                Height="20px" Width="20px" OnClick="campTypeAsc_Click" />
                            <asp:ImageButton ID="campTypeDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                Height="20px" Width="20" OnClick="campTypeDesc_Click" />
                            Campaign Type
                        </th>
                        <th style="width:43px">
                         <asp:ImageButton ID="VIPAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                Height="20px" Width="20" OnClick="campNameAsc_Click" ImageAlign="NotSet" />
                            <asp:ImageButton ID="VIPDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                Height="20px" Width="20" OnClick="campNameDesc_Click" CausesValidation="False" />
                            VIP
                        </th>
                        <th>
                         <asp:ImageButton ID="countryAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                Height="20px" Width="20" OnClick="campNameAsc_Click"/>
                            <asp:ImageButton ID="countryDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                Height="20px" Width="20" OnClick="campNameDesc_Click" CausesValidation="False" />
                            Country
                        </th>
                        <th>
                         <asp:ImageButton ID="brandAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                Height="20px" Width="20" OnClick="campNameAsc_Click" />
                            <asp:ImageButton ID="brandDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                Height="20px" Width="20" OnClick="campNameDesc_Click" CausesValidation="False" />
                            Brand
                        </th>
                        <th>
                         <asp:ImageButton ID="activeAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                Height="20px" Width="20" OnClick="activeAsc_Click" />
                            <asp:ImageButton ID="activeDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                Height="20px" Width="20" OnClick="activeDesc_Click" CausesValidation="False" />
                            Active
                        </th>
                        <th>
                            <asp:ImageButton ID="createdByAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                Height="20px" Width="20px" OnClick="createdByAsc_Click" />
                            <asp:ImageButton ID="createdByDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                Height="20px" Width="20" OnClick="createdByDesc_Click" />
                            Created By
                        </th>
                        <th>
                            <asp:ImageButton ID="campStartAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                Height="20px" Width="20px" OnClick="campStartAsc_Click" />
                            <asp:ImageButton ID="campStartDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                Height="20px" Width="20" OnClick="campStartDesc_Click" />
                            Campaign Start Date
                        </th>
                        <th>
                            <asp:ImageButton ID="campEndAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                Height="20px" Width="20px" OnClick="campEndAsc_Click" />
                            <asp:ImageButton ID="campEndDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                Height="20px" Width="20" OnClick="campEndDesc_Click" />
                            Campaign End Date
                        </th>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr class="repeaterItem">
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "StoreDescription")%>
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "ID") %>
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "CampaignType")%>
                    </td>
                    <td align="center">
                        <asp:CheckBox runat="server" Enabled="false" Checked='<%#DataBinder.Eval(Container.DataItem, "IsVIP")%>' />
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "Country")%>
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "Brand")%>
                    </td>
                    <td align="center">
                        <asp:CheckBox ID="CheckBox1" Enabled="false" runat="server" Checked='<%#DataBinder.Eval(Container.DataItem, "IsActive")%>' />
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "Owner")%>
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "CampaignStartDate", "{0 : dd MMMM yyyy}")%>
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "CampaignEndDate", "{0 : dd MMMM yyyy}")%>
                    </td>
                </tr>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <tr class="repeaterAlternatingItem">
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "StoreDescription")%>
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "ID") %>
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "CampaignType")%>
                    </td>
                    <td align="center">
                        <asp:CheckBox Enabled="false" runat="server" Checked='<%#DataBinder.Eval(Container.DataItem, "IsVIP")%>' />
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "Country")%>
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "Brand")%>
                    </td>
                    <td align="center">
                        <asp:CheckBox ID="CheckBox1" Enabled="false" runat="server" Checked='<%#DataBinder.Eval(Container.DataItem, "IsActive")%>' />
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "Owner")%>
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "CampaignStartDate","{0 : dd MMMM yyyy}")%>
                    </td>
                    <td>
                        <%#DataBinder.Eval(Container.DataItem, "CampaignEndDate", "{0 : dd MMMM yyyy}")%>
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    <p>
        &nbsp;<p>
            <asp:Label ID="lblCurrentPage" runat="server"></asp:Label>
        </p>
        <asp:LinkButton ID="prev" runat="server" onclick="prev_Click">Prev</asp:LinkButton>
        <asp:LinkButton ID="next" runat="server" onclick="next_Click">Next</asp:LinkButton>
        <p>
        </p>
    </p>
</ContentTemplate>

1 个答案:

答案 0 :(得分:0)

我认为您需要处理Repeater的ItemCommand。如果内存服务器控件嵌套在Repeater中,则不会引发事件