不在Web表单中工作 [英] Not working in Web forms
问题描述
从csv文件读取并导入到SQL数据库正在使用windows form apllication.But当我转移web表单时它无法正常工作。
Reading from csv file and import into SQL database is working in windows form apllication.But when i transfered web form its not working.
private void PopulateListBox(ListBox lsb,string Folder,string FileType)
<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
{
{
DirectoryInfo dinfo = new DirectoryInfo(Folder);
DirectoryInfo dinfo = new DirectoryInfo(Folder);
<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
foreach(dinfo.EnumerateFiles(FileType)中的FileInfo文件)
foreach (FileInfo file in dinfo.EnumerateFiles(FileType))
的 <跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;
{
{
lsb.Items.Add(file); - ------> chnaged
此linein网络表单
lsb.Items.Add(file.ToString());
lsb.Items.Add(file); --------> chnaged this linein web form as lsb.Items.Add(file.ToString());
} &NBSP;&NBSP;&NBSP;
}
} }
foreach(ExcelListBox.SelectedItems中的FileInfo selecteditem)
---------->在网络表单中的这一行错误,如
'System.Web.UI.WebControls.ListBox'不包含'SelectedItems'和
的定义
没有扩展方法'SelectedItems'接受'System.Web.UI.WebControls.ListBox'类型的第一个参数'
可以找到(是你错过了using指令或程序集引用?)
  ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
{
{
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
string filepath = selecteditem.FullName;
string filepath = selecteditem.FullName;
<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
使用(TextFieldParser fieldParser = new TextFieldParser(filepath)){这段代码中的错误是什么? 谢谢
using (TextFieldParser fieldParser = new TextFieldParser(filepath)) { whatss the mistake in this code? Thank you
推荐答案
并非所有列表框都相同。 有3种不同类型的列表框
Not all list boxes are the same. There are 3 different type Listboxes
1)ActiveX
1) ActiveX
2)表格
3)Windows
3) Windows
在Excel中,您可以拥有1或2. 如果出现,您的更改从类型3变为类型1或类型。
In Excel you can have either 1 or 2. if appears your change went from a type 3 to either a type 1 or 2.
我认为解决方案类似于以下代码。 我不是因为我不知道你使用的是哪种类型的列表框。
I think the solution is something like the code below. I'mn not usre because I don't know if you which type listbox you are using.
foreach(int index = 0,index < ExcelListbox.Listcount; index ++)
foreach(int index = 0, index < ExcelListbox.Listcount; index++)
{
if(ExcelListBox.List [index] .Selected == true)
if(ExcelListBox.List[index].Selected == true)
{
{
}
}
}
这篇关于不在Web表单中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!