ListBox 请问大家是如何使用 ListBox 这个控件的最好能详细些 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ 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></head><body> <form id="form1" runat="server"> <div> <table style="width: 566px; text-align:center"> <tr> <td> <asp:ListBox ID="ListBox1" runat="server" Width="250px"> <asp:ListItem>aa</asp:ListItem> <asp:ListItem>bb</asp:ListItem> <asp:ListItem>cc</asp:ListItem> <asp:ListItem>dd</asp:ListItem> </asp:ListBox></td> <td><asp:Button ID="btn1" runat="server" Text=">>" OnClick="btn_Click"/><br /><asp:Button ID="btn2" runat="server" Text="<<" OnClick="btn2_Click"/></td> <td> <asp:ListBox ID="ListBox2" runat="server" Width="250px"> <asp:ListItem>aa</asp:ListItem> <asp:ListItem>bb</asp:ListItem> </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) { } protected void btn_Click(object sender, EventArgs e) { if (ListBox1.SelectedIndex.ToString() == "-1") Response.Write(""); else { if (ListBox2.Items.Contains(ListBox1.SelectedItem)) Response.Write(""); else { ListBox2.Items.Add(ListBox1.SelectedItem.Text); ListBox1.Items.Remove(ListBox1.SelectedItem.Text); } } } protected void btn2_Click(object sender, EventArgs e) { if (ListBox2.SelectedIndex.ToString() == "-1") Response.Write(""); else { if (ListBox1.Items.Contains(ListBox2.SelectedItem)) Response.Write(""); else { ListBox1.Items.Add(ListBox2.SelectedItem.Text); ListBox2.Items.Remove(ListBox2.SelectedItem.Text); } } }} div里的table中单击每一行能响应吗? 关于音乐播放的问题 RadioButtonList的问题,请帮忙啊 奇怪的问题,返回后来出现的是html代码 哪位朋友推荐给我一个通用的反编译器 求 CuteEditor 分页解决方案 DataGrid编辑时怎么加上验证控件?页脚怎么加TextBox? 关于AspNetPager分页控件与页面传值的问题 引用DataSet中某个表的某一行中的某一列 急!! 关于WEB页访问局域网内WIN2000SERVER下的目录的问题。分不够可以加!!!! 一个小问题:asp.net能不能调用本地.exe文件? ry如何改变listBox里项的日期格式
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 566px; text-align:center">
<tr>
<td>
<asp:ListBox ID="ListBox1" runat="server" Width="250px">
<asp:ListItem>aa</asp:ListItem>
<asp:ListItem>bb</asp:ListItem>
<asp:ListItem>cc</asp:ListItem>
<asp:ListItem>dd</asp:ListItem>
</asp:ListBox></td>
<td><asp:Button ID="btn1" runat="server" Text=">>" OnClick="btn_Click"/><br /><asp:Button ID="btn2" runat="server" Text="<<" OnClick="btn2_Click"/></td>
<td>
<asp:ListBox ID="ListBox2" runat="server" Width="250px">
<asp:ListItem>aa</asp:ListItem>
<asp:ListItem>bb</asp:ListItem>
</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)
{ }
protected void btn_Click(object sender, EventArgs e)
{
if (ListBox1.SelectedIndex.ToString() == "-1")
Response.Write("");
else
{
if (ListBox2.Items.Contains(ListBox1.SelectedItem))
Response.Write("");
else
{
ListBox2.Items.Add(ListBox1.SelectedItem.Text);
ListBox1.Items.Remove(ListBox1.SelectedItem.Text);
}
}
}
protected void btn2_Click(object sender, EventArgs e)
{
if (ListBox2.SelectedIndex.ToString() == "-1")
Response.Write("");
else
{
if (ListBox1.Items.Contains(ListBox2.SelectedItem))
Response.Write("");
else
{
ListBox1.Items.Add(ListBox2.SelectedItem.Text);
ListBox2.Items.Remove(ListBox2.SelectedItem.Text);
}
}
}
}