做了一个网站,两个Listbox 数据互转listbox1的数据是直接加载的往listbox2中添加时选中无效代码如下 protected void Button3_Click(object sender, EventArgs e)
{
int count = ListBox1.Items.Count;
int index = 0;
for (int i = 0; i < count; i++)
{
ListItem newitem = ListBox1.Items[index];
if (ListBox1.Items[index].Selected == true)
{ ListBox1.Items.Remove(newitem); ListBox2.Items.Add(newitem); }
else { index++; }
}
}ListBox1.Items[index].Selected == true 判断似乎不起作用数据绑定的部分是: .......................................省略部分 SqlDataAdapter da = new SqlDataAdapter(mycom);
DataTable newtable = new DataTable();
da.Fill(newtable);
ListBox1.DataSource = newtable;
ListBox1.DataBind();
mycon.Close();希望高手指教
{
int count = ListBox1.Items.Count;
int index = 0;
for (int i = 0; i < count; i++)
{
ListItem newitem = ListBox1.Items[index];
if (ListBox1.Items[index].Selected == true)
{ ListBox1.Items.Remove(newitem); ListBox2.Items.Add(newitem); }
else { index++; }
}
}ListBox1.Items[index].Selected == true 判断似乎不起作用数据绑定的部分是: .......................................省略部分 SqlDataAdapter da = new SqlDataAdapter(mycom);
DataTable newtable = new DataTable();
da.Fill(newtable);
ListBox1.DataSource = newtable;
ListBox1.DataBind();
mycon.Close();希望高手指教
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货