如何在radgrid中使用自动生成的删除按钮,使用DeleteCommand将radgrid数据绑定中的行删除到数据表中?

时间:2016-07-26 08:09:57

标签: c# telerik radgrid delete-row

我有以下HTML代码:



JmsTemplate




我正在尝试编写<telerik:RadGrid SkinID="RadGridSkin" ID="RadGrid1" runat="server" AutoGenerateColumns="false" ShowFooter="true" ShowHeader="true" RegisterWithScriptManager="false" Width="1000px" OnNeedDataSource="RadGrid1_NeedDataSource" ViewStateMode="Disabled" ShowGroupPanel="false" ClientSettings-Scrolling-AllowScroll="false" GridLines="None" AllowSorting="true" AllowMultiRowSelection="false" HeaderStyle-CssClass="info-title" GroupHeaderItemStyle-CssClass="info" GroupPanel-CssClass="info" CssClass="align-left" HorizontalAlign="Center" AutoGenerateEditColumn="true" AutoGenerateDeleteColumn="true" OnDeleteCommand="RadGrid1_DeleteCommand" OnUpdateCommand="RadGrid1_UpdateCommand"> <ClientSettings> <Selecting AllowRowSelect="false" /> </ClientSettings> <MasterTableView ShowHeadersWhenNoRecords="true"> <NoRecordsTemplate> <div style="text-align: center;"> <asp:Literal ID="NoData_lt" Text="<%$Resources:Strings,Nodatatodisplay %>" runat="server" /> </div> </NoRecordsTemplate> <Columns> <telerik:GridBoundColumn DataField="Name" SortExpression="Name" HeaderText="<%$ Resources:Strings, Name %>" HeaderButtonType="TextButton" /> <telerik:GridBoundColumn DataField="Email" SortExpression="Email" HeaderText="<%$ Resources:Strings, Email%>" HeaderButtonType="TextButton" /> <telerik:GridBoundColumn DataField="Provider" SortExpression="Provider" HeaderText="<%$ Resources:Strings, Provider%>" HeaderButtonType="TextButton" /> <telerik:GridBoundColumn DataField="Warehouse" SortExpression="Warehouse" HeaderText="<%$ Resources:Strings, Warehouse%>" HeaderButtonType="TextButton" /> </Columns> </MasterTableView> </telerik:RadGrid>事件的代码:

&#13;
&#13;
RadGrid1_DeleteCommand
&#13;
&#13;
&#13;

如何获取点击自动生成 protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e) { int i; //I want i to represent the index of row to be deleted DataRow dr = testTable.Rows[i]; dr.Delete(); }的{​​{1}}的{​​{1}}并将其保存在我的index变量中?

0 个答案:

没有答案