从列表框中插入多个值 [英] insert multiple value from listbox
问题描述
我做了这个编码,但我发现错误是什么......
==>两个列表框==> lst_leftstar和lst_rightstar
项目从lst_leftstar传递到lst_rightstar
和
编码为==>> lst_rightstar值存储在数据库中。
==>> 2张桌子
==> < 1为卤素; starmaster
starid
star
==>> < 2 - ;简介明星
profilestar
starid
xml查询完美写好
但是问题在于编码..
我的代码是:=
i done this coding but i cant find that what is the mistake....
==>two listbox ==> lst_leftstar and lst_rightstar
items pass from lst_leftstar to lst_rightstar
and
coding for ==>> lst_rightstar values store in database.
==>> 2 tables
==> <1> starmaster
starid
star
==>> <2> profile star
profilestar
starid
xml query is perfect written
but problem is in the coding..
my code is :=
protected void btnsumit_partner_details_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Star_Id");
for (int i = 0; i < lst_rightstar.Items.Count; i++)
{
dt.Rows.Add("");
dt.Rows[i]["Star_Name"] = lst_rightstar.Items[i].Value;
}
clsregisterinfo.Dtstd = dt;
clsregisterinfo.insert_data();
}
==>我的问题在这里。
当id调试时我看到... for循环不起作用..
表示...当我跟踪代码时... .i无法进入for循环..
和vales在类文件中传递null。
==> my problm is here.
that when id debug i see that...for loop isn't worked..
means...when i trace the code...i cant enter in for loop..
and vales pass null in class file.
推荐答案
即使你的问题有点模糊,但根据我的理解问题如下,这就是为什么它没有进入for loop
我想您正在尝试将项目从lst_leftstar
移至lst_rightstar
,并且在开始时您将尝试移动一个项目从左到右,右侧列表框将为空,即item.count = 0.因此它不会进入循环。
我想你替换这个
Even though your question is bit vague, but as per my understanding problem is as below and this is the reason why its not entering thefor loop
I think you are trying to move item from thelst_leftstar
tolst_rightstar
, and when at the start you will try to move an item from left to right, the right listbox will be empty i.e. item.count = 0. hence it will not enter for loop.
and I think you replace this
for(int i = 0; i< lst_rightstar.Items.Count; i ++)
for (int i = 0; i < lst_rightstar.Items.Count; i++)
with
with
for (int i = 0; i < lst_leftstar.Items.Count; i++)
我希望它能解决你没有进入for循环的问题。
循环有一个列不匹配的错误。
一开始你要添加一个名为Star_Id的列
I hope it will solve your problem of not entering in for loop.
Further inside the loop there is a mistake of column mismatch.
on the start you are adding a column named Star_Id
dt.Columns.Add(Star_Id);
dt.Columns.Add("Star_Id");
在循环内你试图在
dt.Rows [i] [Star_Name]
dt.Rows[i]["Star_Name"]
即名为Star_Name的列,您之前未添加..
希望它能帮到你.. :)
i.e. Column Named as Star_Name which you have not added before..
Hope it will help you.. :)
抱歉,我......忘了告诉你..那个/>
i使用javascript将项目从lst_leftstar移动到lst_rightstar(双击)
。
此编码仅适用于数据库中插入lst_rightstar项目。
我有这个问题(for loop)
sorry dr...i forgot to tell you..that
i move items from lst_leftstar to lst_rightstar using javascript(doubleclick)
.
this coding is just only for insert lst_rightstar items in database..
and i have this problem(for loop)
protected void btnsumit_partner_details_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Star_Id");
for (int i = 0; i < lst_rightstar.Items.Count; i++)
{
dt.Rows.Add("");
dt.Rows[i]["Star_Id"] = lst_rightstar.Items[i].Value;
}
clsregisterinfo.Dtstd = dt;
clsregisterinfo.insert_data();
}
请再次查看或循环
please check it again or loop
这篇关于从列表框中插入多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!