我有一个asp.net GridView转换为jquery datatable当我点击GridView内的一个按钮时,数据表格式丢失,并在控制台中抛出错误
这是源代码中的GridView:
<!-- GridView -->
<asp:UpdatePanel runat="server" ID="pnlGrid" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvMovies" runat="server" AutoGenerateColumns="False" CssClass="table table-bordered myTable" EmptyDataText="No data found !"
OnRowCommand="gvMovies_RowCommand" AllowPaging="true" PageSize="5" OnPageIndexChanging="gvMovies_PageIndexChanging"
OnRowDataBound="gvMovies_RowDataBound">
<HeaderStyle CssClass="thead-dark text-center" />
<Columns>
<asp:BoundField DataField="Id" HeaderText="Référence" HeaderStyle-CssClass="d-none" ItemStyle-CssClass="d-none" />
<asp:BoundField DataField="Title" HeaderText="Title" />
<asp:BoundField DataField="Genre" HeaderText="Genre" />
<asp:BoundField DataField="Year" HeaderText="Year" />
<asp:BoundField DataField="Rate" HeaderText="Rate" />
<asp:TemplateField HeaderText="Actions" ItemStyle-CssClass="text-center">
<ItemTemplate>
<!-- View button with icon -->
<asp:LinkButton runat="server" ID="btnView" CssClass="btn btn-info btn-sm btn-view"
CommandName="btnView"
CommandArgument='<%# Eval("Id") %>'>
<i class="bi bi-eye-fill text-white"></i>
</asp:LinkButton>
<!-- Edit button with icon -->
<asp:LinkButton runat="server" ID="btnEdit" CssClass="btn btn-warning btn-sm" ClientIDMode="Static" EnableViewState="true" ViewStateMode="Enabled" CommandName="btnEdit" CommandArgument='<%# Eval("Id") %>'>
<i class="bi bi-pencil-fill text-white"></i>
</asp:LinkButton>
<!-- Delete button with icon -->
<asp:LinkButton runat="server" ID="btnDelete" CssClass="btn btn-danger btn-sm" CommandName="btnDelete" CommandArgument='<%# Eval("Id") %>'>
<i class="bi bi-trash-fill text-white"></i>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
字符串
1条答案
按热度按时间rks48beu1#
在绑定gridview之后以及在每个回发事件上使用此代码。
字符串
这应该能解决你的问题。