DropDownList 选定的值和表格
问:
嗨,我有一个下拉列表,但出现两个错误。
错误#1:我的要求是从下拉列表中选择会议名称,将其保存到字符串中并稍后使用该字符串。我想从数据库表中获取字段值(它为我提供存储文件的路径)。
代码:
string selected = DropDownList1.SelectedValue.ToString();
var query = from meet in db.Meets
where meet.Summary = selected
select meet.Doc_Path;
我在“where meet.Summary=selected
”处收到错误,它显示
“无法隐式转换字符串类型 布尔”
错误 #2: 我希望使用通过查询获得的 Doc_Path
值。我不确定语法和因此,当我尝试时出现错误
代码:
string[] dirs = Directory.GetDirectories(query);
请帮忙。
Q:
Hi,I have a dropdownlist and i get two errors.
Error #1: My requirement is selecting the meeting name from the dropdownlist, saving it into a string and using that string later. I want to get the field value (which gives me the path where the files are stored) from the database table.
The code :
string selected = DropDownList1.SelectedValue.ToString();
var query = from meet in db.Meets
where meet.Summary = selected
select meet.Doc_Path;
I get an error at "where meet.Summary=selected
" and it says
"cannot implicitly convert type string
to bool"
Error #2: I wish to use the Doc_Path
value which I get through the query. I am not sure of the syntax and hence getting an error when I tried it.
The code:
string[] dirs = Directory.GetDirectories(query);
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
错误 #1 - 我认为您需要 == 而不是 =
错误 #2 - 您可能需要使用
Server.MapPath
或者,将它们结合起来
Error # 1 - I think you need == instead of just =
Error #2 - You may need to user
Server.MapPath
or, to combine them
错误#1:
正如之前所说,在进行比较时应该使用
==
而不是=
。错误#2:
为什么使用
Directory.GetDirectories(query);
前面的方法用于获取指定目录中的子目录名称(包括其路径)。
看看这里
我认为你不需要这个方法,只需使用:
确保
meet.Doc_Path
值不是绝对路径,仅存储相对路径。Error # 1:
As said before ,you should use
==
instead of=
when making comparison .Error # 2:
Why you use
Directory.GetDirectories(query);
the previous method is used to Get the names of subdirectories (including their paths) in the specified directory.
look here
i think you don't need this method, just use :
Make sure that the
meet.Doc_Path
value is n't the absolute path, store only the relative path.