<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OverTime.aspx.cs" Inherits="OverTime" %>
<!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 id="Head1" runat="server">
<title>Untitled Page</title>
<style type="text/css">
#div1
{
width: 606px;
height: 400px;
border: 1px solid #ffffff;
}
#div2
{
position: absolute;
left: 5px;
width: 200px;
height: 400px;
border: 1px solid #ffffff;
}
#div3
{
top: 150px;
text-align: center;
position: absolute;
left: 205px;
width:50px;
height: 100px;
border: 1px solid #ffffff;
}
#div4
{
position: absolute;
left: 255px;
width: 200px;
height: 400px;
border: 1px solid #ffffff;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<br />
<br />
<br />
班组:<br />
<asp:DropDownList ID="DropDownList1" runat="server" Height="40px" Width="188px"
AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="bm_name"
DataValueField="bm_name">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Data Source=SRV-KS-DB;Initial Catalog=form_new1;Persist Security Info=True;User ID=ten;Password=19850610"
ProviderName="System.Data.SqlClient"
SelectCommand="SELECT [bm_name] FROM [All_bm]"></asp:SqlDataSource>
<div id="div1">
<div id="div2">
<asp:ListBox ID="ListBox1" runat="server" Height="390px" Width="190px"
DataSourceID="SqlDataSource2" DataTextField="ry_name" DataValueField="ry_name"
></asp:ListBox>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="Data Source=SRV-KS-DB;Initial Catalog=form_new1;Persist Security Info=True;User ID=ten;Password=19850610"
ProviderName="System.Data.SqlClient"
SelectCommand="SELECT [ry_name] FROM [All_user] WHERE ([bm_name] = @bm_name)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="bm_name"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<div id="div3">
<table cellpadding="0" cellspacing="0" >
<tr>
<td>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text=">" Width="25px"
οnclick="Button1_Click" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button2" runat="server" Text=">>" Width="25px"
οnclick="Button2_Click" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button3" runat="server" Text="<" Width="25px"
οnclick="Button3_Click" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button4" runat="server" Text="<<" Width="25px"
οnclick="Button4_Click" />
</td>
</tr>
</table>
</div>
<div id="div4">
<asp:ListBox ID="ListBox2" runat="server" Height="390px" Width="190px"></asp:ListBox>
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></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 OverTime : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < ListBox1.Items.Count; i++)
{
if (ListBox1.Items[i].Selected == true)
{
ListBox2.Items.Add(new ListItem(ListBox1.Items[i].Text, ListBox1.Items[i].Value));
ListBox1.Items.Remove(ListBox1.Items[i].Value);
}
}
}
protected void Button3_Click(object sender, EventArgs e)
{
for (int i = 0; i < ListBox2.Items.Count; i++)
{
if (ListBox2.Items[i].Selected == true)
{
ListBox1.Items.Add(new ListItem(ListBox2.Items[i].Text, ListBox2.Items[i].Value));
ListBox2.Items.Remove(ListBox2.Items[i].Value);
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
ListBox1.DataBind();
ListBox2.DataSource = ListBox1.Items;
ListBox2.DataBind();
ListBox1.Items.Clear();
}
protected void Button4_Click(object sender, EventArgs e)
{
ListBox2.Items.Clear();
ListBox1.DataBind();
}
}