gridview 中的数据下移一行 下移一行
gridview 数据绑定后,我加了两个模板列LinkButton, "上移 "和 "下移 "
我现在已经搞定了RowCreated 和 RowCommand
当点击某行的linkbutton时,我可以知道当前的行号
我有一个按钮,是循环gridview 按表格里的顺序 更新库里的排序号
我想点击 "上移 "或 "下移 "时,让这两行的内容交换位置,这个如何实现?
有好的方法吗?
------解决方案--------------------似乎要用脚本了...
可惜,偶脚本不怎么样
------解决方案--------------------up
------解决方案--------------------HTML页面两个BTN
<asp:LinkButton ID= "uplinkbtn " CommandName= "up " CommandArgument= ' <%# Eval( "subjectid ") %> ' OnClientClick= 'return confirm( "确定上移吗? ") ' runat= "server "> 向上移动 </asp:LinkButton>
<asp:LinkButton ID= "downlinkbtn " CommandName= "down " CommandArgument= ' <%# Eval( "subjectid ") %> ' OnClientClick= 'return confirm( "确定下移吗? ") ' runat= "server "> 向下移动 </asp:LinkButton>
======ItemCommend事件里面.cs代码
private static LinkButton linkbtn, linkbtn1;
/// <summary>
/// RP命令事件
/// </summary>
/// <param name= "source "> </param>
/// <param name= "e "> </param>
protected void DLBlogSubjectList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
Repeater repeater;
switch (e.CommandName)
{
case "del ":
linkbtn = (LinkButton)e.Item.FindControl( "dellinkbtn ");
if (BLL.BSubject.DelSubject(Convert.ToInt32(linkbtn.CommandArgument)))
{
Common.JScript.Alert( "删除成功! ");
}
else
{
Common.JScript.Alert( "删除失败! ");
}
iniDataList(this.getFormParm( "sqlWhere "));
break;
case "modify ":
swin2.Visible = true;
linkbtn = (LinkButton)e.Item.FindControl( "modifylinkbtn ");
break;
case "up ":
linkbtn = (LinkButton)e.Item.FindControl( "uplinkbtn ");
repeater = (Repeater)source;
if (e.Item.ItemIndex > 0)
{
linkbtn1 = (LinkButton)repeater.Items[e.Item.ItemIndex - 1].FindControl( "uplinkbtn ");
if (BLL.BSubject.UpSubjectOrderNum(Convert.ToInt32(linkbtn.CommandArgument), Convert.ToInt32(linkbtn1.CommandArgument)))
{
Common.JScript.Alert( "向上移动成功! ");
}
else
{
Common.JScript.Alert( "向上移动失败! ");
}
iniDataList(this.getFormParm( "sqlWhere "));
}
else
{
Common.JScript.Alert( "已经是最上面一级了! ");
}
break;
case "down ":
linkbtn = (LinkButton)e.Item.FindControl( "downlinkbtn ");
repeater = (Repeater)source;
if (e.Item.ItemIndex + 1 < repeater.Items.Count)
{
linkbtn1 = (LinkButton)re