应该是你把LIstBox1中的选的项加到ListBox2中的时候出错了,没加进去,ListBox2中的Item是空的
解决方案 »
- C# 调用VC++内部类
- 上午面试.NET去了,不会的题大家研究下
- 一个我也不懂意思的问题
- 请教一个正则表达式
- c# 项目开发实训 人事档案管理系统
- 关于SelectedIndexChanged事件的一个問題(winform)
- 我准备写web组件,在web组件中不能用session()??不认的
- 这个问题一定要星星回答,不是星星顶顶也有分,不够再加哦~!
- datagirdview新增行出现的问题
- C# 字符串有什么简单效率安全性高的问题
- 在vs2005中,在向页面中拖一table控件时,看不见该控件,在xml:lang 该组件的getvalue操作失败,生成错误代码0x80070057
- 连接未关闭。连接的当前状态为已打开(十万火急!!)
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 btnOk_Click(object sender, EventArgs e)
{
string aa = ListBox1.Items.Count.ToString(); ArryList list=new ArryList();
string bb = ListBox2.Items.Count.ToString(); foreach(string str in ListBox1.Items)
string km = ""; {
for (int i = 0; i < ListBox2.Items.Count; i++) ListBox2.Items.Add(str)
{ }
km += this.ListBox2.Items[i].Text.ToString() + ",";
}
Response.Write(km);
}
}
我想要的效果是ListBox2的项是从ListBox1里选择的其中几个(不一定全部)
现在是前台页面上能把ListBox1的值选中并添加到ListBox2里,但后台取ListBox2的值是却不能取得值(ListBox2里已经有刚添加的项目的)
一样的道理 lixtbox有个选中事件 判断下就ok了
listBox2.Items.Add(str);
但当前台选中通过ListBox选进后,又觉得多选了从ListBox2删除了已选中的项,或者ListBox2的内容是通过多次从ListBox1里添加得来的,这时就不对了啊,有没有什么更好一点的办法呢,不知是不是我前台有什么问题啊,或者后台在哪个位置应该用上if(!IspostBack)呢
帮我看看嘛
在你的Page_Load里面加一个If(!IspostBack)