秦岭过客
当我发现自己已经很牛B的时候,却发现别人已经超过我很多-----虚心学习,永不止步
博客园
首页
新随笔
联系
订阅
管理
随笔 - 48 文章 - 16 评论 - 0 trackbacks - 3
<
2009年7月
>
日
一
二
三
四
五
六
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
此处所写,只代表本人在某一阶段的认识和见解
MSN:qin.jinxiang@hotmail.com
QQ:303019286
与我联系
发短消息
搜索
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的参与
我的标签
我参与的团队
SharePoint团队(0/0)
北京.NET俱乐部(0/0)
微软(西安).NET开发俱乐部(0/0)
我的标签
Sql 日期输出的格式样式
(1)
GridView 自动增加序号
(1)
随笔档案
2009年3月 (1)
2009年1月 (1)
2008年12月 (2)
2008年11月 (1)
2008年10月 (1)
2008年8月 (2)
2007年11月 (1)
2007年9月 (5)
2007年8月 (3)
2007年7月 (3)
2007年6月 (23)
2007年5月 (2)
2007年4月 (1)
2006年11月 (2)
文章档案
2007年4月 (1)
2006年11月 (15)
我的链接
C# yaosansi
jaron.cn
阿吴的BLOGS
老姜
孟子E章
深圳.NET俱乐部
邹建
最新随笔
1. SQL存储过程实现分页
2. sql 查询
3. 常用正则表达式验证
4. GridView 自动增加序号
5. Sql 日期输出的格式样式
6. gridview 删除提示框
7. sql 分页
8. DropdownList绑定
9. MOSS 2007基础:WSS 3.0 中的母版页(Master Pages)和内容页(Content Pages)
10. 对象池是什么,本人的拙见
积分与排名
积分 - 25048
排名 - 2326
阅读排行榜
1. mysql创建新用户并设权限命令(2969)
2. GridView基本的操作 编辑 更新 取消(一)(2736)
3. DataList编辑、更新、取消、删除、分页(分页控件AspNetPager.dll)(2066)
4. SQL字符串函数(1995)
5. Asp.Net toString() 的妙用[处理日期,字符型转换 转为字符串](1966)
asp.net2.0 ListBox控件左移右移
//
前台代码:
<%
@ Page Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
ListBox.aspx.cs
"
Inherits
=
"
ListBox
"
%>
<!
DOCTYPE html PUBLIC
"
-//W3C//DTD XHTML 1.0 Transitional//EN
"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
"
>
<
html xmlns
=
"
http://www.w3.org/1999/xhtml
"
>
<
head runat
=
"
server
"
>
<
title
>
无标题页
</
title
>
<
script language
=
"
javascript
"
type
=
"
text/javascript
"
>
function btn_right_onclick()
{
var select_ListBox_left
=
document.getElementById(
"
ListBox_left
"
);
var select_ListBox_right
=
document.getElementById(
"
ListBox_right
"
);
var count
=
0
;
for
(i
=
0
; i
<
select_ListBox_left.length; i
++
)
{ count
=
0
;
if
(select_ListBox_left.options[i].selected)
{
var temp
=
document.createElement(
"
option
"
);
temp.value
=
select_ListBox_left[i].value;
temp.text
=
select_ListBox_left[i].value;
if
(select_ListBox_right.length
==
0
)
{
select_ListBox_right.add(temp);
}
else
{
for
(j
=
0
; j
<
select_ListBox_right.length; j
++
)
{
if
(select_ListBox_right.options[j].value
==
temp.value)
{
count
++
;
}
}
if
(count
==
0
)
{
select_ListBox_right.add(temp);
}
}
}
}
}
function btn_QuanBu_right_onclick()
{
var select_ListBox_left
=
document.getElementById(
"
ListBox_left
"
);
var select_ListBox_right
=
document.getElementById(
"
ListBox_right
"
);
for
(i
=
select_ListBox_right.length; i
>=
0
; i
--
)
{
select_ListBox_right.remove([i]);
}
if
(select_ListBox_right.length
==
0
)
{
for
(i
=
0
; i
<
select_ListBox_left.length; i
++
)
{
var temp
=
document.createElement(
"
option
"
);
temp.value
=
select_ListBox_left[i].value;
temp.text
=
select_ListBox_left[i].value;
select_ListBox_right.add(temp);
}
}
}
function btn_left_onclick()
{
var select_ListBox_right
=
document.getElementById(
"
ListBox_right
"
);
var tmp
=
select_ListBox_right.length;
for
(i
=
0
; i
<
select_ListBox_right.length; i
++
)
{
//
alert(select_ListBox_right.length);
if
(select_ListBox_right.options[i].selected)
{
//
alert(i);
select_ListBox_right.remove([i]);
i
--
;
}
}
}
function btn_QuanBu_left_onclick()
{
var select_ListBox_left
=
document.getElementById(
"
ListBox_left
"
);
var select_ListBox_right
=
document.getElementById(
"
ListBox_right
"
);
for
(i
=
select_ListBox_right.length; i
>=
0
; i
--
)
{
select_ListBox_right.remove([i]);
}
}
function btn_top_onclick()
{
var select_ListBox_right
=
document.getElementById(
"
ListBox_right
"
);
var selectedIndex
=
select_ListBox_right.selectedIndex;
var count
=
0
;
if
(select_ListBox_right.length
!=
0
)
{
for
(i
=
0
; i
<
select_ListBox_right.length; i
++
)
{
if
(selectedIndex
!=
0
)
{
if
(select_ListBox_right.options[i].selected)
{
count
++
;
}
}
else
{
return
;
}
}
if
(count
!=
0
)
{
if
(selectedIndex
<=
select_ListBox_right.length
-
1
)
{
var temp
=
document.createElement(
"
option
"
);
temp.text
=
select_ListBox_right.options[select_ListBox_right.selectedIndex].text;
temp.value
=
select_ListBox_right.options[select_ListBox_right.selectedIndex].value;
select_ListBox_right.options[select_ListBox_right.selectedIndex].text
=
select_ListBox_right.options[select_ListBox_right.selectedIndex
-
1
].text;
select_ListBox_right.options[select_ListBox_right.selectedIndex].value
=
select_ListBox_right.options[select_ListBox_right.selectedIndex
-
1
].value;
select_ListBox_right.options[select_ListBox_right.selectedIndex
-
1
].text
=
temp.text;
select_ListBox_right.options[select_ListBox_right.selectedIndex
-
1
].value
=
temp.value;
select_ListBox_right.selectedIndex
=
select_ListBox_right.selectedIndex
-
1
;
}
}
else
{
alert(
"
没有选中一个!
"
);
}
}
else
{
alert(
"
没有数据
"
);
}
}
function btn_bottom_onclick()
{
var select_ListBox_right
=
document.getElementById(
"
ListBox_right
"
);
var selectedIndex
=
select_ListBox_right.selectedIndex;
var count
=
0
;
if
(select_ListBox_right.length
!=
0
)
{
for
(i
=
0
; i
<
select_ListBox_right.length; i
++
)
{
if
(selectedIndex
!=
select_ListBox_right.length
-
1
)
{
if
(select_ListBox_right.options[i].selected)
{
count
++
;
}
}
else
{
return
;
}
}
if
(count
!=
0
)
{
if
(selectedIndex
<=
select_ListBox_right.length
-
1
)
{
var temp
=
document.createElement(
"
option
"
);
temp.text
=
select_ListBox_right.options[select_ListBox_right.selectedIndex].text;
temp.value
=
select_ListBox_right.options[select_ListBox_right.selectedIndex].value;
select_ListBox_right.options[select_ListBox_right.selectedIndex].text
=
select_ListBox_right.options[select_ListBox_right.selectedIndex
+
1
].text;
select_ListBox_right.options[select_ListBox_right.selectedIndex].value
=
select_ListBox_right.options[select_ListBox_right.selectedIndex
+
1
].value;
select_ListBox_right.options[select_ListBox_right.selectedIndex
+
1
].text
=
temp.text;
select_ListBox_right.options[select_ListBox_right.selectedIndex
+
1
].value
=
temp.value;
select_ListBox_right.selectedIndex
=
select_ListBox_right.selectedIndex
+
1
;
}
}
else
{
alert(
"
没有选中一个!
"
);
}
}
else
{
alert(
"
没有数据
"
);
}
}
</
script
>
</
head
>
<
body
>
<
form id
=
"
form1
"
runat
=
"
server
"
>
<
div
>
<
table width
=
"
250px
"
border
=
"
0
"
cellpadding
=
"
0
"
cellspacing
=
"
0
"
>
<
tr
>
<
td
><
asp:ListBox ID
=
"
ListBox_left
"
SelectionMode
=
"
Multiple
"
Height
=
"
200px
"
Width
=
"
110px
"
runat
=
"
server
"
></
asp:ListBox
></
td
>
<
td
>
<
input id
=
"
btn_right
"
type
=
"
button
"
value
=
"
>
"
onclick
=
"
return btn_right_onclick()
"
/>
<
input id
=
"
btn_QuanBu_right
"
type
=
"
button
"
value
=
"
>>
"
onclick
=
"
return btn_QuanBu_right_onclick()
"
/>
<
input id
=
"
btn_left
"
type
=
"
button
"
value
=
"
<
"
onclick
=
"
return btn_left_onclick()
"
/>
<
input id
=
"
btn_QuanBu_left
"
type
=
"
button
"
value
=
"
<<
"
onclick
=
"
return btn_QuanBu_left_onclick()
"
/>
<
input id
=
"
btn_top
"
type
=
"
button
"
value
=
"
↑
"
onclick
=
"
return btn_top_onclick()
"
/>
<
input id
=
"
btn_bottom
"
type
=
"
button
"
value
=
"
↓
"
onclick
=
"
return btn_bottom_onclick()
"
/>
</
td
>
<
td
><
asp:ListBox ID
=
"
ListBox_right
"
SelectionMode
=
"
Multiple
"
Height
=
"
200px
"
Width
=
"
110px
"
runat
=
"
server
"
></
asp:ListBox
></
td
>
</
tr
>
</
table
>
</
div
>
</
form
>
</
body
>
</
html
>
//
后台代码:
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
public
partial
class
ListBox : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(
!
IsPostBack)
{
ListBox_DataBind();
}
}
private
void
ListBox_DataBind()
{
XBGQWZ.BusinessLayer.T_Modle bus_role
=
new
XBGQWZ.BusinessLayer.T_Modle();
DataSet ds
=
bus_role.GetList(
""
);
for
(
int
i
=
0
; i
<
ds.Tables[
0
].Rows.Count; i
++
)
{
this
.ListBox_left.Items.Add(ds.Tables[
0
].Rows[i][
1
].ToString());
}
}
}
posted on 2006-11-12 08:49
秦岭过客
阅读(247)
评论(0)
编辑
收藏
网摘
所属分类:
ASP.NET