将倾斜的列表框项目显示到另一个GridView中 [英] Display Slected ListBox Items into another GridView
本文介绍了将倾斜的列表框项目显示到另一个GridView中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI,
我在Gridview中有一个ListBox.现在,我想将列表框项目的选定项目显示到另一个Gridview中.
谁能帮我做到这一点.
I have a ListBox inside a Gridview. Now, I want to display selected Items of ListBox items into another Gridview.
Can anyone help me to do this.
ListBox LstBox = (dgi.FindControl("lstType") as ListBox);
string strselect = "";
for (int j = 0; j < LstBox.Items.Count; j++)
{
ListItem li = LstBox.Items[j];
if (li.Selected)
{
strselect = strselect + ", " + li.Value;
}
}
if (strselect.Length > 0)
{
strselect = strselect.Remove(0, 2);
}
dr["Type"] = strselect;
提前感谢....
Thanx in advance....
推荐答案
DataTable dtData = new DataTable();
dtData.Columns.Add("Selected");
DataRow dr = dtData.NewRow();
dr["Selected] = ListBox1.Selectedvalue.ToString();
dtData.Rows.Add(dr);
GridView1.DataSource = dtData.Copy();
GridView1.DataBind();
这篇关于将倾斜的列表框项目显示到另一个GridView中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文