Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在不刷新整个页面的情况下获得刷新的表?_C#_Jquery_Asp.net - Fatal编程技术网

C# 如何在不刷新整个页面的情况下获得刷新的表?

C# 如何在不刷新整个页面的情况下获得刷新的表?,c#,jquery,asp.net,C#,Jquery,Asp.net,我正在开发一个ASP.NET intranet web应用程序,它是一个测验引擎。因为我是一名新的ASP.NET开发人员,所以我有一个表,显示从用户那里收到的一些反馈,管理员可以使用DropDownList接受或拒绝这些反馈 在这个表下,有一个JQuery手风琴,当管理员点击它时,他会看到一个表,其中包含过去三个月收到的反馈。但是,当管理员接受或拒绝其中一个反馈,然后单击手风琴时,他将看到该表,但没有该反馈,即使该反馈是上个月提交的反馈之一。然而,当你刷新页面,然后点击手风琴,他会看到它 那么,

我正在开发一个ASP.NET intranet web应用程序,它是一个测验引擎。因为我是一名新的ASP.NET开发人员,所以我有一个表,显示从用户那里收到的一些反馈,管理员可以使用DropDownList接受或拒绝这些反馈

在这个表下,有一个JQuery手风琴,当管理员点击它时,他会看到一个表,其中包含过去三个月收到的反馈。但是,当管理员接受或拒绝其中一个反馈,然后单击手风琴时,他将看到该表,但没有该反馈,即使该反馈是上个月提交的反馈之一。然而,当你刷新页面,然后点击手风琴,他会看到它

那么,是否有任何功能可以帮助我在刷新整个页面的同时自动刷新表格? 有什么帮助吗?

ASP.NET代码:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" 
                        width="950px" CssClass="mGrid"
                        AlternatingRowStyle-CssClass="alt" 
                        RowStyle-HorizontalAlign="Center" 
                        DataSourceID="SqlDataSource1" 
                        OnRowDataBound="GridView1_RowDataBound" >
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <HeaderStyle Font-Bold = "true" ForeColor="Black" Height="20px"/> 
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                <asp:BoundField DataField="Description" HeaderText="Description" 
                    SortExpression="Description" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Username" HeaderText="Username" 
                    SortExpression="Username" />
                <asp:BoundField DataField="DivisionShortcut" HeaderText="Division" 
                    SortExpression="DivisionShortcut" />
                <asp:TemplateField HeaderText="Status">
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList" runat="server" DataSourceID="SqlDataSource2"
                                          Font-Bold="True" ForeColor="#006666" AppendDataBoundItems="false" 
                                          DataTextField="Status" DataValueField="ID" AutoPostBack="true" 
                                          OnDataBound="DropDownList_DataBound" OnSelectedIndexChanged ="DropDownList_SelectedIndexChanged">
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:testConnectionString %>" 
            SelectCommand="SELECT     dbo.SafetySuggestionsLog.ID, dbo.SafetySuggestionsLog.Title, dbo.SafetySuggestionsLog.Description, dbo.employee.Name, dbo.SafetySuggestionsLog.Username, 
                      dbo.Divisions.DivisionShortcut
FROM         dbo.employee INNER JOIN
                      dbo.SafetySuggestionsLog ON dbo.employee.Username = dbo.SafetySuggestionsLog.Username INNER JOIN
                      dbo.Divisions ON dbo.employee.DivisionCode = dbo.Divisions.SapCode"
                      FilterExpression="[DivisionShortcut] like '{0}%'">

                      <FilterParameters>
                        <asp:ControlParameter ControlID="ddlDivision" Name="DivisionShortcut" 
                                                 PropertyName="SelectedValue" Type="String" />
                    </FilterParameters>
        </asp:SqlDataSource>

        <%--For the DropDownList--%>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                            ConnectionString="<%$ ConnectionStrings:testConnectionString %>" 
                            SelectCommand="SELECT * FROM [SafetySuggestionsStatus]">
        </asp:SqlDataSource>

        <%--Filtering by Division--%>
        <asp:SqlDataSource ID="sqlDataSourceDivision" runat="server" 
        ConnectionString="<%$ ConnectionStrings:testConnectionString %>" 
        SelectCommand="SELECT [DivisionShortcut] FROM [Divisions]"></asp:SqlDataSource>

<dl id="jfaq">
            <br />
                <dt>Safety Suggestions List (for the last three months)</dt>
                    <dd> 
                        <br />
                        <asp:Panel ID="Panel1" runat="server">
                        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                                      AllowSorting="True" CssClass="mGrid"
                                      AlternatingRowStyle-CssClass="alt" 
                                      RowStyle-HorizontalAlign="Center" 
                                      DataSourceID="SqlDataSource4">
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            <HeaderStyle Font-Bold = "true" ForeColor="Black" Height="20px"/> 
                            <Columns>
                                <asp:BoundField DataField="SubmittedMonth" HeaderText="Submitted Month" 
                                    SortExpression="SubmittedMonth" ReadOnly="True" />
                                <asp:BoundField DataField="DivisionShortcut" HeaderText="Division" 
                                    SortExpression="DivisionShortcut" />
                                <asp:BoundField DataField="Username" HeaderText="Username" 
                                    SortExpression="Username" />
                                <asp:BoundField DataField="Name" HeaderText="Name" 
                                    SortExpression="Name" />
                                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                                <asp:BoundField DataField="Description" HeaderText="Description" 
                                    SortExpression="Description" />
                                <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
                                <asp:BoundField DataField="Status" HeaderText="Status" 
                                    SortExpression="Status" />
                            </Columns>
                                <RowStyle HorizontalAlign="Center"></RowStyle>
                        </asp:GridView>
                        </asp:Panel>
                        <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:testConnectionString %>" SelectCommand="SELECT     TOP (100) PERCENT LEFT(DATENAME(month, dbo.SafetySuggestionsLog.DateSubmitted), 3) + '-' + DATENAME(year, dbo.SafetySuggestionsLog.DateSubmitted) 
                      AS SubmittedMonth, dbo.Divisions.DivisionShortcut, dbo.SafetySuggestionsLog.Username, dbo.employee.Name, dbo.SafetySuggestionsLog.Title, 
                      dbo.SafetySuggestionsLog.Description, dbo.SafetySuggestionsType.Type, dbo.SafetySuggestionsStatus.Status
FROM         dbo.Divisions INNER JOIN
                      dbo.employee ON dbo.Divisions.SapCode = dbo.employee.DivisionCode INNER JOIN
                      dbo.SafetySuggestionsLog ON dbo.employee.Username = dbo.SafetySuggestionsLog.Username INNER JOIN
                      dbo.SafetySuggestionsType ON dbo.SafetySuggestionsLog.TypeID = dbo.SafetySuggestionsType.ID INNER JOIN
                      dbo.SafetySuggestionsStatus ON dbo.SafetySuggestionsLog.StatusID = dbo.SafetySuggestionsStatus.ID
WHERE     (DATEDIFF(month, dbo.SafetySuggestionsLog.DateSubmitted, GETDATE()) &lt; 3)
ORDER BY dbo.SafetySuggestionsLog.DateSubmitted DESC">
                       </asp:SqlDataSource>

                       <asp:Button ID="btnPrint" runat="server" Text="Print" OnClick="btnPrint_Click" />
                       </dd>
                 </dl>
更新: 我使用UpdatePanel控件获得部分更新,并且使用了
,但是我得到了以下错误,我不知道为什么:

在关联控件上找不到名为“Click”的事件 UpdatePanel“UpdatePanel1”中触发器的“GridView2”



安全建议清单(最近三个月)

使用ajax更新面板这可能有助于触发您提到的单击事件,但在后面的代码中,您只有DropDownList\u SelectedIndexChanged事件

相反,您可以触发DropDownList的SelectedIndexChanged事件,如下所示:

    <asp:AsyncPostBackTrigger ControlID="DropDownList" EventName="SelectedIndexChanged" />

谢谢你的帮助。但是您的意思是我应该只将Jquery手风琴放在UpdatePanel控件中吗?或者我也应该使用触发器?@AliAhmed将触发器中的控件id更改为导致网格视图绑定的控件的名称,我认为在您的情况下是下拉列表..并将事件名称更改为SelectedIndexChangedHanks。非常感谢您的帮助。更新后请刷新网格。您可以使用GridView2.DataBind()谢谢。我真的很感谢你的帮助。
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="GridView2" EventName="Click" />
    </Triggers>
    <ContentTemplate>
       <dl id="jfaq">
            <br />
                <dt>Safety Suggestions List (for the last three months)</dt>
                    <dd> 
                        <br />
                        <asp:Panel ID="Panel1" runat="server">
                        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                                      AllowSorting="True" CssClass="mGrid"
                                      AlternatingRowStyle-CssClass="alt" 
                                      RowStyle-HorizontalAlign="Center" 
                                      DataSourceID="SqlDataSource4">
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            <HeaderStyle Font-Bold = "true" ForeColor="Black" Height="20px"/> 
                            <Columns>
                                <asp:BoundField DataField="SubmittedMonth" HeaderText="Submitted Month" 
                                    SortExpression="SubmittedMonth" ReadOnly="True" />
                                <asp:BoundField DataField="DivisionShortcut" HeaderText="Division" 
                                    SortExpression="DivisionShortcut" />
                                <asp:BoundField DataField="Username" HeaderText="Username" 
                                    SortExpression="Username" />
                                <asp:BoundField DataField="Name" HeaderText="Name" 
                                    SortExpression="Name" />
                                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                                <asp:BoundField DataField="Description" HeaderText="Description" 
                                    SortExpression="Description" />
                                <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
                                <asp:BoundField DataField="Status" HeaderText="Status" 
                                    SortExpression="Status" />
                            </Columns>
                                <RowStyle HorizontalAlign="Center"></RowStyle>
                        </asp:GridView>
                        </asp:Panel>
                        <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:testConnectionString %>" SelectCommand="SELECT     TOP (100) PERCENT LEFT(DATENAME(month, dbo.SafetySuggestionsLog.DateSubmitted), 3) + '-' + DATENAME(year, dbo.SafetySuggestionsLog.DateSubmitted) 
                      AS SubmittedMonth, dbo.Divisions.DivisionShortcut, dbo.SafetySuggestionsLog.Username, dbo.employee.Name, dbo.SafetySuggestionsLog.Title, 
                      dbo.SafetySuggestionsLog.Description, dbo.SafetySuggestionsType.Type, dbo.SafetySuggestionsStatus.Status
FROM         dbo.Divisions INNER JOIN
                      dbo.employee ON dbo.Divisions.SapCode = dbo.employee.DivisionCode INNER JOIN
                      dbo.SafetySuggestionsLog ON dbo.employee.Username = dbo.SafetySuggestionsLog.Username INNER JOIN
                      dbo.SafetySuggestionsType ON dbo.SafetySuggestionsLog.TypeID = dbo.SafetySuggestionsType.ID INNER JOIN
                      dbo.SafetySuggestionsStatus ON dbo.SafetySuggestionsLog.StatusID = dbo.SafetySuggestionsStatus.ID
WHERE     (DATEDIFF(month, dbo.SafetySuggestionsLog.DateSubmitted, GETDATE()) &lt; 3)
ORDER BY dbo.SafetySuggestionsLog.DateSubmitted DESC">
                       </asp:SqlDataSource>

                       <asp:Button ID="btnPrint" runat="server" Text="Print" OnClick="btnPrint_Click" />
                       </dd>
                 </dl>

       </ContentTemplate>
    </asp:UpdatePanel>
    <asp:AsyncPostBackTrigger ControlID="DropDownList" EventName="SelectedIndexChanged" />
    GridView2.DataBind();