English 中文(简体)
图像Button在重复控制下燃烧
原标题:ImageButton does nt fire OnItemCommand in repeater control

everyone! I m writing repeater control on my web-page. After I added data paging for repeater I have got problem: ImageButton does nt fire any more OnItemCommand event of repeater. Why?

这里是标记法的一部分:

 <asp:Repeater ID="PartsRepeater" runat="server"
                    OnItemCommand="partsRepeater_ItemCommand"
                    OnItemDataBound="partsRepeaterItem_Bound">
                    <HeaderTemplate>
                        <table rules="all" cellspacing="0" style="border-color: rgb(31, 77, 48);
                            border-style: solid; width: 100%; border-collapse: collapse;">
                            <tr >
                                <td style="width: 92%;">
                                    <table cellspacing="0" border="0" style="border-color: rgb(31, 77, 48); border-style: solid;
                                        width: 100%; border-collapse: collapse;">
                                        <tr style="background-color: #1f4d30; color: white;">
                                            <td style="width: 10%;">
                                                <asp:Label runat="server" Text="Name" ID="lblName">
                                                </asp:Label>
                                            </td>
                                            <td style="width: 10%;">
                                                <asp:Label runat="server" Text="Number" ID="Label64">
                                                </asp:Label>
                                            </td>
                                            <td style="width: 10%;">
                                                <asp:Label runat="server" Text="Category" ID="Label65">
                                                </asp:Label>
                                            </td>
                                            <td style="width: 20%;">
                                                <asp:Label runat="server" Text="Description" ID="Label66">
                                                </asp:Label>
                                            </td>
                                            <td style="width: 20%;">
                                                <asp:Label runat="server" Text="Models" ID="Label67">
                                                </asp:Label>
                                            </td>
                                            <td style="width: 5%;">
                                                <asp:Label runat="server" Text="Price" ID="Label68">
                                                </asp:Label>
                                            </td>
                                            <td style="width: 5%;">
                                                <asp:Label runat="server" Text="A Qty" ID="Label69">
                                                </asp:Label>
                                            </td>
                                            <td style="width: 5%;">
                                                <asp:Label runat="server" Text="B Qty" ID="Label70">
                                                </asp:Label>
                                            </td>
                                            <td style="width: 5%;">
                                                <asp:Label runat="server" Text="Actual Qty" ID="Label71">
                                                </asp:Label>
                                            </td>
                                            <td style="width: 5%;">
                                                <asp:Label runat="server" Text="Total Qty" ID="Label72">
                                                </asp:Label>
                                            </td>
                                            <td style="width: 5%;" >
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td style="width: 8%;" >
                                </td>
                            </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr style="border-color: #1f4d30;"
                         >
                        <td style="width: 92%;">
                                <table border="0" cellspacing="0" class="PartsRepeater_InnerTable">
                                    <tr class="PartsRepeater_InnerTable">
                                        <td style="cursor: pointer; width: 10%;" class="PartsRepeater_InnerTable">
                                            <asp:HiddenField runat="server" ID="PartID" Value= <%# Bind("PartID") %>  Visible="false" />
                                            <asp:LinkButton runat="server" ID="Label52" Text= <%#Eval("Name").ToString()%>  CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                        <td style="cursor: pointer; width: 10%;" class="PartsRepeater_InnerTable">
                                            <asp:LinkButton ID="Label45" runat="server" Text= <%#Eval("Number").ToString().ToUpper()%> 
                                                CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                        <td style="cursor: pointer; width: 20%;" class="PartsRepeater_InnerTable">
                                            <asp:LinkButton ID="Label46" runat="server" Text= <%#Eval("Category").ToString()%> 
                                                CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                        <td style="cursor: pointer; width: 20%;" class="PartsRepeater_InnerTable">
                                            <asp:LinkButton ID="Label47" runat="server" Text= <%# GetPartDescr((String)Eval("Description"))%> 
                                                CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                        <td style="cursor: pointer; width: 5%;" class="PartsRepeater_InnerTable">
                                            <asp:LinkButton ID="Label48" runat="server" Text=   <%# GetPartDescr((String)Eval("ModelName")) %> 
                                                CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                        <td style="cursor: pointer; width: 4%;" class="PartsRepeater_InnerTable">
                                            <asp:LinkButton ID="Label49" runat="server" Text= <%# GetPrice(Eval("Price").ToString(), Eval("sPrice").ToString(), Eval("Price3").ToString())%> 
                                                CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                        <td style="cursor: pointer; width: 4%;" class="PartsRepeater_InnerTable">
                                            <asp:LinkButton ID="lblAQTY" runat="server" Text=  <%#Eval("AGradeQty").ToString()%> 
                                                CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                        <td style="cursor: pointer; width: 4%;" class="PartsRepeater_InnerTable">
                                            <asp:LinkButton ID="lblBQty" runat="server" Text=  <%# int.Parse(Eval("QtyInStock").ToString()) - int.Parse(Eval("AGradeQty").ToString())%> 
                                                CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                        <td style="cursor: pointer; width: 4%;" class="PartsRepeater_InnerTable">
                                            <asp:LinkButton ID="lblActualQTY" runat="server" Text=  <%#Eval("ActualQty").ToString()%> 
                                                CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                        <td style="cursor: pointer; width: 4%;" class="PartsRepeater_InnerTable"> 
                                            <asp:LinkButton ID="Label60" runat="server" Text= <%#Eval("QtyInStock").ToString()%> 
                                                CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                    </tr>
                                    <tr >
                                        <td colspan="15" style="cursor: pointer; width: 5%;">
                                            <asp:LinkButton ID="Label63" runat="server" Text= <%#Eval("priceModificationDate").ToString()%> 
                                                Font-Size="Smaller" CommandArgument= <%# Eval("PartID") %> >
                                            </asp:LinkButton>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td style="width: 8%">
                                <table>
                                    <tr>
                                        <td style="cursor: pointer; width: 50%;" class="PartsRepeater_InnerTable">
                                            <asp:ImageButton ID="btnEdit" runat="server" ImageUrl="~/Images/edit.png" CausesValidation="False"
                                                CommandName="editRow" CommandArgument= <%# Eval("PartID") %>  OnClientClick= SaveScrollPositions >
                                            </asp:ImageButton>
                                        </td>
                                        <td style="cursor: pointer; width: 50%;">
                                            <asp:ImageButton ID="btnDelete" runat="server" OnClientClick= <%# GetConfirmMessage(Eval("Name"))%> 
                                                ImageUrl="~/Images/delete.png" CausesValidation="False" CommandName="Delete"
                                                CommandArgument= <%# Eval("PartID") %> ></asp:ImageButton>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </asp:Repeater>
最佳回答

I ve tried nany ways to solve this problem and solved it so: I just replace ImageButton with linkButton with image: Part og code:

<td style="cursor: pointer; width: 50%;" class="PartsRepeater_InnerTable">
                                            <asp:LinkButton ID="btnEdit" runat="server" CausesValidation="false" CommandName="editRow"
                                                CommandArgument= <%# Eval("PartID") %>  OnClientClick= SaveScrollPositions >
                                                <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/edit.png" />
                                            </asp:LinkButton>
                                        </td>
                                        <td style="cursor: pointer; width: 50%;">
                                            <asp:LinkButton ID="btnDelete" runat="server" CausesValidation="false" CommandName="Delete"
                                                CommandArgument= <%# Eval("PartID") %>  OnClientClick= <%# GetConfirmMessage(Eval("Name"))%> >
                                                <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/delete.png" />
                                            </asp:LinkButton>
                                        </td>

详见:http://weblogs.asp.net/justinsaraceno/archive/2008/11/05/linkbutton-with-image-and-text.aspx

问题回答

职业介绍我没有更具体的答案,但与复读者的观点有所不同,使复读者重新具有约束力。

很显然,当回击发生时,当你重新吸收复读时,它就失去了一些具有约束力的事件,而不是管理奥通德,而是把它当作象布特顿公司首页的负荷。 AFAIK只出现在图像Button,而不是LinkButton或Button。

在其后面的法典中阐明这一点肯定会奏效。

if (!Page.IsPostBack)
{
    REPEATERDATABIND(); // Bind method
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签