fineui 的grid 中如何删除勾选的项
就是想删除打勾的几项要怎么实现<x:GridID="grid1"Title="表格"AllowSorting="true"SortDirection="ASC"Width...
就是想删除打勾的几项
要怎么实现
<x:Grid ID="grid1" Title="表格" AllowSorting="true" SortDirection="ASC" Width="750px" AutoHeight="true" runat="server" EnableCheckBoxSelect="True" DataKeyNames="Id,Name,AtSchool" EnableRowNumber="True" OnSort="grid1_Sort" > <Columns> <x:BoundField Width="100px" ID="name" SortField="Name" DataField="GSM" DataFormatString="{0}" HeaderText="姓名" /> <x:BoundField Width="100px" SortField="EntranceYear" DataField="GQM" HeaderText="歌曲名" /> </Columns> </x:Grid> <x:Button ID="btn" runat="server" OnClick="btn_Click" Text="确定"></x:Button> 展开
要怎么实现
<x:Grid ID="grid1" Title="表格" AllowSorting="true" SortDirection="ASC" Width="750px" AutoHeight="true" runat="server" EnableCheckBoxSelect="True" DataKeyNames="Id,Name,AtSchool" EnableRowNumber="True" OnSort="grid1_Sort" > <Columns> <x:BoundField Width="100px" ID="name" SortField="Name" DataField="GSM" DataFormatString="{0}" HeaderText="姓名" /> <x:BoundField Width="100px" SortField="EntranceYear" DataField="GQM" HeaderText="歌曲名" /> </Columns> </x:Grid> <x:Button ID="btn" runat="server" OnClick="btn_Click" Text="确定"></x:Button> 展开
3个回答
展开全部
整个过程思想就是遍历所选择的行,对逐个行进行删除
var selectedCount = Grid1.SelectedRowIndexArray.Length;
if (selectedCount <= 0)
{
Alert.Show("您未选择任意一行!", MessageBoxIcon.Warning);
return;
}
var idList = new List<long>();
for (var i = 0; i < selectedCount; i++)
{
var rowIndex = Grid1.SelectedRowIndexArray[i];
var keys = Grid1.DataKeys[rowIndex];
var id = long.Parse(keys[0].ToString());
idList.Add(id );
}
foreach (var id in idList)
{
Delete(id );
}
GridDataBind();
//每行记录都有一个与之对应的ID对吧,so,删除时根据ID删除
//你的Grid绑定不知道是怎么绑定的,可能根据其他进行删除
var selectedCount = Grid1.SelectedRowIndexArray.Length;
if (selectedCount <= 0)
{
Alert.Show("您未选择任意一行!", MessageBoxIcon.Warning);
return;
}
var idList = new List<long>();
for (var i = 0; i < selectedCount; i++)
{
var rowIndex = Grid1.SelectedRowIndexArray[i];
var keys = Grid1.DataKeys[rowIndex];
var id = long.Parse(keys[0].ToString());
idList.Add(id );
}
foreach (var id in idList)
{
Delete(id );
}
GridDataBind();
//每行记录都有一个与之对应的ID对吧,so,删除时根据ID删除
//你的Grid绑定不知道是怎么绑定的,可能根据其他进行删除
展开全部
fineui 好用吗?一直没用过!!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询