telerik:RadGrid 表格中删除数据
<telerik:RadGrid OnItemCommand="RadGrid1_ItemCommand" AutoGenerateColumns="False" ID="RadGrid1" runat="server" CellSpacing="0" Height="490px" Culture="zh-CN" CssClass="gridTable" GridLines="Both" AllowPaging="True" AllowSorting="true" PageSize="50" OnNeedDataSource="RadGrid1_NeedDataSource" HeaderStyle-HorizontalAlign="Center"> <ExportSettings HideStructureColumns="true" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" /> <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" /> <ClientSettings EnableRowHoverStyle="true" AllowColumnsReorder="true" ReorderColumnsOnClient="true"> <Resizing AllowColumnResize="True" EnableRealTimeResize="True" /> <Scrolling AllowScroll="true" UseStaticHeaders="true" /> <Selecting AllowRowSelect="True" /> </ClientSettings> <MasterTableView Width="100%" ClientDataKeyNames="编号" DataKeyNames="编号" CommandItemDisplay="Top" EditMode="InPlace" > <Columns> <telerik:GridTemplateColumn HeaderText="序号" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <%#Container.ItemIndex + 1%> </ItemTemplate> <HeaderStyle Width="40" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="描述" > <ItemTemplate> <%# Eval("描述")%> </ItemTemplate> <HeaderStyle Width="150"></HeaderStyle> <EditItemTemplate> <telerik:RadTextBox ID="描述" Width="100%" runat="server" Text=' <%# Eval("描述")%>'></telerik:RadTextBox> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="内容" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <%# Eval("内容")%> </ItemTemplate> <HeaderStyle Width="50"></HeaderStyle> <EditItemTemplate> <telerik:RadTextBox ID="内容" Width="100%" runat="server" Text=' <%# Eval("内容")%>' ></telerik:RadTextBox> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridEditCommandColumn HeaderStyle-Width="6%" UniqueName="Edit" EditText="编辑" HeaderText="编辑" ItemStyle-HorizontalAlign="Center"> </telerik:GridEditCommandColumn>
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmText="确认要删除吗?" UniqueName="DeleteColumn"
ConfirmDialogType="Classic" HeaderText="删除" Text="删除" HeaderStyle-Width="5%"
ItemStyle-HorizontalAlign="Center" ImageUrl="../Skins/Ibm/Content/icons/Delete.gif">
</telerik:GridButtonColumn>
</Columns> </MasterTableView> </telerik:RadGrid>
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { try { GridEditableItem item = e.Item as GridEditableItem; if (e.CommandName == "Delete") { string 编号 = item.GetDataKeyValue("编号").ToString(); // 根据编号查询数据 //得到这些数据之后 进行相应的方法处理 进行修改数据 } } catch (Exception Exc) { throw; } }