日期:2014-05-18 浏览次数:20583 次
ArrayList objArrayList = new ArrayList();
foreach (object a in listBox1.Items) {
objArrayList.Add(a);
}
------解决方案--------------------
写了一个,你试一下
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
<asp:ListBox ID="ListBox1" runat="server" Height="279px" Width="294px">
<asp:ListItem>张三</asp:ListItem>
<asp:ListItem>李四</asp:ListItem>
<asp:ListItem>王老五</asp:ListItem>
</asp:ListBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="取值" Width="179px" /></div>
</form>
</body>
</html>
------解决方案--------------------
这其实是简单的一个循环遍历问题,如1楼和2楼所述,还有就是看你要取它的text和value了。。。