更新面板刷新ASP.Net gridview
我在更新面板中有一个ASP.Net网格视图。我在Modalpopup扩展器中显示数据。我还使用实体框架下面的代码有效,但我需要确保我使用的是最佳实践 Net网格视图更新面板刷新ASP.Net gridview,asp.net,gridview,Asp.net,Gridview,我在更新面板中有一个ASP.Net网格视图。我在Modalpopup扩展器中显示数据。我还使用实体框架下面的代码有效,但我需要确保我使用的是最佳实践 Net网格视图 <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="serv
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="grdOutput" />
<asp:AsyncPostBackTrigger ControlID="btnDelete" />
<asp:AsyncPostBackTrigger ControlID="btnSave" />
</Triggers>
<ContentTemplate>
<asp:Button ID="btnNew" OnClick="btnNew_Click" Text=" new" runat="server"/>
<asp:GridView ID="grdOutput" runat="server" Width="200px" AutoGenerateColumns="False" DataKeyNames="Id" >
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:LinkButton ID="lnkEdit" runat="server" OnClick="lnkEdit_Click">Edit</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=FMPEntities" DefaultContainerName="FMPCommsEngEntities" EnableFlattening="False" EntitySetName="OutputTypes" EntityTypeFilter="OutputType">
</asp:EntityDataSource>
<asp:Panel ID="pnlEdit" runat="server" CssClass="modalPopup" style = "display:none">
<table >
<tr><td colspan="2"> Output Type Details</td></tr>
<tr>
<td>
<asp:Label ID="lblOutputTypeID" runat="server" Text="ID"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtOutPutTypeID" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblName" runat="server" Text="Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtOutputTypeName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> <asp:Button ID="btnSave" runat="server" OnClick="Save" Text="Save" /></td>
<td><asp:Button ID="btnCancel" runat="server" Text="Cancel" /></td>
<td><asp:Button Id="btnDelete" runat="server" Text="Delete" OnClick="Delete" /></td>
</tr>
</table>
</asp:Panel>
<asp:Panel ID="pnlAdd" runat="server" CssClass="modalPopup" style = "display:none">
<table >
<tr><td colspan="2"> Output Type Details</td></tr>
<tr>
<td>
<asp:Label ID="lblADDName" runat="server" Text="Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtAddName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> <asp:Button ID="btnADDSave" runat="server" OnClick="Insert" Text="Save" /></td>
<td><asp:Button ID="btnCancel1" runat="server" Text="Cancel" /></td>
</tr>
</table>
</asp:Panel>
<cc1:ModalPopupExtender ID="popup" runat="server" CancelControlID="btnCancel" DropShadow="false" PopupControlID="pnlEdit" TargetControlID = "link" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<cc1:ModalPopupExtender ID="AddPopup" runat="server" CancelControlID="btnCancel1" DropShadow="true" PopupControlID="pnlAdd" TargetControlID = "Addlink" BackgroundCssClass="modalBackground" > </cc1:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
我试图使用UpdatePanel1.update()
但是gridview
没有刷新
刷新
网格视图的最佳方法是什么?
UpdatePanel1.update()不会更新网格。保存/删除方法中的方式是正确的。你需要重新绑定它。由于更新面板触发器已编码,更新面板刷新将自动进行。这与经典ASP无关。请取下标签。
Protected Sub Save(sender As Object, e As EventArgs)
UpdateOutputType(Integer.Parse(txtOutPutTypeID.Text), txtOutputTypeName.Text)
grdOutput.DataSource = EntityDataSource1
grdOutput.DataBind()
End Sub
Protected Sub Delete(sender As Object, e As EventArgs)
DeleteOutputType(Integer.Parse(txtOutPutTypeID.Text))
grdOutput.DataSource = EntityDataSource1
grdOutput.DataBind()
End Sub