秦岭过客
夹缝中求生存
博客园
首页
新随笔
联系
订阅
管理
随笔 - 54 文章 - 17 评论 - 0 trackbacks - 3
<
2012年2月
>
日
一
二
三
四
五
六
29
30
31
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
1
2
3
4
5
6
7
8
9
10
此处所写,只代表本人在某一阶段的认识和见解
MSN:qin.jinxiang@hotmail.com
QQ:303019286
邮箱:jinxiang_qin@126.com
昵称:
秦岭过客
园龄:
5年3个月
粉丝:
2
关注:
0
搜索
常用链接
我的随笔
我的评论
我的参与
最新评论
我的标签
最新随笔
1. sql删除连接对象资源管理器的实例
2. jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关
3. firebug 快捷键
4. sql 递归
5. JavaScript 中使用 replace 达到 replaceAll的效果
6. 服务器共享对话框
7. SQL存储过程实现分页
8. sql 查询
9. 常用正则表达式验证
10. GridView 自动增加序号
我的标签
Sql 日期输出的格式样式
(1)
GridView 自动增加序号
(1)
随笔档案
2011年8月 (1)
2011年3月 (3)
2010年6月 (1)
2009年9月 (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
myDate97
阿吴的BLOGS
老姜
孟子E章
深圳.NET俱乐部
邹建
积分与排名
积分 - 39703
排名 - 2695
阅读排行榜
推荐排行榜
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
秦岭过客
阅读(568)
评论(0)
编辑
收藏
注册用户登录后才能发表评论,请
登录
或
注册
,
返回博客园首页
。
首页
博问
闪存
新闻
园子
招聘
知识库
最新IT新闻
:
·
《纽约时报》:富士康问题犯错不只苹果
·
传微软拟新开4家专卖店 首家海外店今年开张
·
亚马逊否认近期将推出独立视频服务
·
微软高管称企业用户升级Windows 8应先更新Windows 7
·
分析师称苹果三星上季度占据手机市场95%利润
»
更多新闻...
最新知识库文章
:
·
高级编程语言的发展历程
·
如何学习一门新的编程语言?
·
学习不同编程语言的重要性
·
为什么我喜欢富于表达性的编程语言
·
计算机专业的女生为什么要学编程
»
更多知识库文章...
China-pub 2011秋季教材巡展
China-Pub 计算机绝版图书按需印刷服务