【问题标题】:ASP.NET gridview control in side update panel has a problem侧面更新面板中的 ASP.NET gridview 控件有问题
【发布时间】:2010-05-14 18:40:33
【问题描述】:

您好,

我有带有 SelectedIndexChanged 事件的 gridview。

当我单击 gridview 中的记录时,它应该调用 SelectedIndexChanged 事件并执行一些操作。

SelectedIndexChanged 事件工作正常,但是当我将 gridview 放入 ajax updatepanle 时,即使我为 SelectedIndexChanged 事件添加 AsyncPostBackTrigger 触发器,SelectedIndexChanged 事件也不会响应。

请查看我的代码并建议我应该怎么做!!

谢谢

<%@ Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="IMAM_APPLICATION.WebForm1" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

     <div id="mydiv">

         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
         <ContentTemplate>


  <br />  <br />
                <br />
    <asp:GridView ID="GridView1" runat="server" 

                        style="position:absolute; top: 280px; left: 30px; height: 240px; width: 915px;" 
                        PageSize="5" 
                    onselectedindexchanged="GridView1_SelectedIndexChanged" 
                        AutoGenerateColumns="False" DataKeyNames="idcontact_info">
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField AccessibleHeaderText="Midle Name" DataField="Midle_Name" />
                        <asp:BoundField DataField="Last_Name" HeaderText="Last Name" />
                        <asp:BoundField DataField="Phone_home" HeaderText="Phone Home" />
                        <asp:BoundField DataField="cell_home" HeaderText="Mobile Home" />
                        <asp:BoundField DataField="phone_work" HeaderText="Phone Work" />
                        <asp:BoundField DataField="cell_Work" HeaderText="Mobile Work" />
                        <asp:BoundField DataField="Email_Home" HeaderText="Personal Home" />
                        <asp:BoundField DataField="Email_work" HeaderText="Work Email" />
                    </Columns>
                </asp:GridView>

                <br />  

         <br />
                <br /></ContentTemplate>
             <Triggers>
                 <asp:AsyncPostBackTrigger ControlID="GridView1" 
                     EventName="SelectedIndexChanged" />
             </Triggers>
         </asp:UpdatePanel>


               <asp:RadioButton ID="rdoSearchFlat" runat="server" 
                    style="position:absolute; top: 565px; left: 70px;" Text="Flat Search" 
                    GroupName="Search"/>

                    <asp:TextBox ID="txtSearch" runat="server" 
                    style="position:absolute; top: 560px; left: 170px;" ></asp:TextBox>

                    <asp:Button ID="btnSearch" runat="server" Text="Search" 
                    style="position:absolute; top: 555px; left: 375px;" 
                    CausesValidation="False" onclick="btnSearch_Click"/>

                    <asp:Label ID="Label7" runat="server" Style="position: absolute; top: 630px; left: 85px;"
                    Text="First Name"></asp:Label>

                 <asp:TextBox ID="txtFirstName" runat="server" Style="top: 630px; left: 185px; position: absolute;
                    height: 22px; width: 128px">
                    </asp:TextBox>   



</div>    
</asp:Content>

【问题讨论】:

    标签: asp.net-ajax updatepanel


    【解决方案1】:

    我错过了一些东西,我应该将所有我想触发的控件放在更新面板中。

    【讨论】:

      【解决方案2】:

      您需要在UpdatePanel 中使用SyncPostBack 并将Control 的ID 分配给UpdatePanel 中的ControlID

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-09-02
        • 1970-01-01
        • 2010-12-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-19
        • 2010-10-08
        相关资源
        最近更新 更多