<asp:UctlGridViewExtender ID="GridView1" Width="200px" AutoGenerateScrollBar="true" VScrollHeight="150px" CssClass="GridView" runat="server" OnRowDataBound="GridView1_RowDataBound"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="选择">
<ItemTemplate>
<input id="ItemCheck" type="checkbox" />
</ItemTemplate>
<HeaderStyle CssClass="GridViewFixedHeader" Width="30px" />
<ItemStyle CssClass="GridViewItem" Width="30px" />
<FooterStyle CssClass="GridViewFixedFooter" Width="30px" />
</asp:TemplateField>
<asp:BoundField DataField="ItemGroupName" HeaderText="分组名称" ReadOnly="True">
<HeaderStyle CssClass="GridViewFixedHeader" Width="170px" />
<ItemStyle CssClass="GridViewItem" Width="170px" />
<FooterStyle CssClass="GridViewFixedFooter" Width="170px" />
</asp:BoundField>
</Columns>
<RowStyle CssClass="GridViewRow" />
<AlternatingRowStyle CssClass="GridViewAlternatingRow" />
<EmptyDataRowStyle CssClass="GridViewEmptyDataRow" />
<SelectedRowStyle CssClass="GridViewSelectedRow" />
<EditRowStyle CssClass="GridViewEditRowStyle" />
</asp:UctlGridViewExtender>
<script language="javascript" type="text/javascript">
var chkList = document.getElementsByName("ItemCheck");
function upClick(){
var intRowNum = chkClick();
if (intRowNum == -1)
{
return false;
}else if(intRowNum == 0)
{
alert("已是顶部!");
}else
{
var tb = document.getElementById('<%= GridView1.ClientID%>');
tb.moveRow(intRowNum,intRowNum-1);
chkList[intRowNum-1].checked = true;
}
return false;
}
function downClick(){
var intRowNum = chkClick();
if (intRowNum == -1)
{
return false;
}else if (intRowNum == chkList.length-1)
{
alert("已是底部!");
}else
{
var tb = document.getElementById('<%= GridView1.ClientID%>');
tb.moveRow(intRowNum,intRowNum+1);
chkList[intRowNum+1].checked = true;
}
return false;
}
function chkClick(){
var checkedList = "";
var arrchecked = "";
var intFlg = 0;
var intReturn = 0;
for(var i=0; i<chkList.length; i++){
if(chkList[i].checked)
{
intFlg++;
intReturn = i;
}
}
if (intFlg == 0)
{
alert("请选择要移动的行!");
}else if (intFlg > 1)
{
alert("只可以单选!");
}else{
return intReturn;
}
return -1;
}
</script>