简体   繁体   中英

itemcommand in datalist for image button does not fire in first click

my code is

<asp:DataList EnableTheming="false" ID="dlDocument" ShowHeader="false" ShowFooter="false"
RepeatColumns="3" runat="server" OnItemCommand="dlDocument_ItemCommand" DataKeyField="Id"
RepeatDirection="Horizontal" OnItemDataBound="dlDocument_ItemDataBound">

<ItemTemplate>
    <table border="0" cellpadding="0" cellspacing="0" dir="ltr" align="center">
        <tr>
            <td class="C2-TL"></td>
            <td class="C2-TM"></td>
            <td class="C2-TR"></td>
        </tr>
        <tr>
            <td class="C2-LM">&nbsp;
            </td>
            <td class="C2-Content">
                <table width="110" border="0" cellpadding="0" cellspacing="0" align="center">
                    <tr>
                        <td align="center" valign="top" width="14">
                            <asp:ImageButton ToolTip="ویرایش" ID="btnUpdate" CommandName="Update" runat="server" Height="12px" OnClientClick="editDocList(<%#((Document)Container.DataItem).Id%>)"
                                Width="12px" ImageUrl="/App_Themes/Default/Images/GridIcons/Grid-Edit.png" />
                            <br />
                            <asp:ImageButton ToolTip="حذف" OnClientClick="javascript:return confirm('آیا مطمئن به حذف هستید؟');return false;"
                                ID="btnDelete" CommandName="Delete" runat="server" Height="12px" Width="13px"
                                ImageUrl="/App_Themes/Default/Images/GridIcons/Grid-delete.png" />
                        </td>
                        <td align="center" rowspan="2">
                            <asp:Label ID="lblImg" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" valign="top" width="16">
                            <a href="javascript:" title="چاپ تصویر در اندازه A4" onclick='SendToPrint("<%#"/Handlers/ImageHandler.ashx?id=" +((Document)Container.DataItem).Id%>");'>
                                <img alt="چاپ تصویر" src="<%=Radyn.Contracts.Application.Settings.DNNPath %>/Images/GridIcons/print.png" border="0" height="16"
                                    width="16" />
                            </a>
                        </td>
                    </tr>
                    <tr>
                        <td width="14"></td>
                        <td align="center" height="25">
                            <asp:Label ID="lblDesc" runat="server"></asp:Label>
                        </td>
                    </tr>
                </table>
            </td>
            <td class="C2-RM">&nbsp;
            </td>
        </tr>
        <tr>
            <td class="C2-BL2"></td>
            <td class="C2-BM2"></td>
            <td class="C2-BR2"></td>
        </tr>
    </table>
</ItemTemplate>

the problem is when i click on image button edit or delete in first click not firing itemcommand event ,but in second click fire that

i have this datalist in usercontrol(.ascx) data list is in default.aspx==>view.ascx==>docLink.asx

i call default.aspx in window.open

oh after a lot of R&D in internet and my friends i found the answer the answer is when you load dynamically a user Control to your form you should set the ID to control That want to add

for example my control is Doclist i add Doclist.ID="docList";

the problem was solved

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM