开发者

asp.net Update Panel capturing Button clicks

I have a page that has an ASP.NET UpdatePanel on it. The UpdatePanel contains a repeater, and within the repeater is a command button. (please see the code example below)

When I click on the button the first time, nothing happens. But the second time I click on the same button, then I get the event I was expecting triggered. I am at a loss as to why this is, though I am sure there is a simple explanation. Any advice would be helpful.

<!-- Drivers Table -->
                    <asp:UpdatePanel runat="server" ID="DriverUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="true">
                        <ContentTemplate>    
                            <asp:HiddenField runat="server" ID="DriverErrors" />
                            <asp:Repeater ID="DriverRepeater" runat="server" OnItemData开发者_C百科Bound="DriverRepeater_ItemDataBound" OnItemCommand="DriverRepeater_ItemCommand">
                                <HeaderTemplate>
                                    <table cellspacing="0" class="section-table">
                                        <tr>
                                            <td class="bg_mid" colspan="7"><img src="/images/sections/drivers.png" alt="Drivers" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_1 left-cell">#</td>
                                            <td class="text_1">Name</td>
                                            <td class="text_1">Date Of Birth</td>
                                            <td class="text_1">Gender</td>
                                            <td class="text_1">License #</td>
                                            <td class="text_1">Relationship</td>
                                            <td class="text_1" align="right">&nbsp;</td>
                                        </tr>
                                </HeaderTemplate>
                                <ItemTemplate>
                                        <tr id="DriverRow" runat="server">
                                            <td class="text_2 required left-cell"><asp:Label ID="DriverNumber" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "DriverNumber")%>'></asp:Label></td>
                                            <td class="text_2 required"><asp:Label ID="DriverName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "FirstName")%>'></asp:Label></td>
                                            <td class="text_2 required"><asp:Label ID="BirthDate" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "BirthDate")%>'></asp:Label></td>
                                            <td class="text_2 required"><asp:Label ID="Gender" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Gender").ToString() == "F" ? "Female" : "Male" %>'></asp:Label></td>
                                            <td class="text_2 required"><asp:Label ID="DriversLicenseNumber" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "LicenseInformation.DriversLicenseNumber")%>'></asp:Label></td>
                                            <td class="text_2 required"><asp:Label ID="RelationshipToApplicant" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "RelationshipToApplicant")%>'></asp:Label></td>
                                            <td class="text_2 right-cell" align="right"><asp:ImageButton runat="server" ID="DriverEditButton" 
                                                ImageUrl="/images/edit.jpg" AlternateText="Edit" CommandName="Edit" CausesValidation="false" /></td>
                                        </tr>
                                </ItemTemplate>
                                <FooterTemplate>
                                    </table>
                                </FooterTemplate>
                            </asp:Repeater>
                        </ContentTemplate>
                    </asp:UpdatePanel>


make UpdatePanel Mode="Conditional" and enableviewstate="true" you not need to defined trigger and you work is done without it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜