score:2
Accepted answer
Error # 1 - I think you need == instead of just =
string selected = DropDownList1.SelectedValue.ToString();
var query = from meet in db.Meets
where meet.Summary == selected
select meet.Doc_Path;
Error #2 - You may need to user Server.MapPath
String FilePath;
FilePath = Server.MapPath(query);
or, to combine them
string selected = DropDownList1.SelectedValue.ToString();
var query = from meet in db.Meets
where meet.Summary == selected
select Server.MapPath(meet.Doc_Path);
string[] dirs = Directory.GetDirectories(query);
score:0
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 :
string selected = DropDownList1.SelectedValue.ToString();
var query = from meet in db.Meets
where meet.Summary == selected
select meet.Doc_Path;
string dirPath = System.Web.HttpContext.Current.Server.MapPath("~") + query.ToString();
Make sure that the meet.Doc_Path
value is n't the absolute path, store only the relative path.
Source: stackoverflow.com
Related Articles
- DropDownList selectedvalue and tables
- How to reuse a linq expression for 'Where' when using multiple source tables
- LINQ Source Code Available
- .NET 4 Code Contracts: "requires unproven: source != null"
- creating Linq to sqlite dbml from DbLinq source code
- Need a LINQ code example to link two tables that have no foreign key
- Linq Boolean returns exception DROPDOWNLIST has a SelectedValue which is invalid because it does not exist in the list of item
- source code for LINQ 101 samples
- Comparing data from 2 tables and display the result on a dropdownlist using LINQ
- List or Array of String Contain specific word in Html Source Code
- IQueryable two tables from Code First Entity Framework
- c# Linq or code to extract groups from a single list of source data
- Code throws Invalid cast exception: linq-sql join two tables
- Showing joined tables in retrieve function in EF using Code First
- Linq where clause tied to dropdownlist selectedvalue
- i am trying to join 3 tables below is the code
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Value cannot be null. Parameter name: source
- Linq code to select one item
- C# - code to order by a property using the property name as a string
- How to perform Join between multiple tables in LINQ lambda
- How do I find the text within a div in the source of a web page using C#
- Roslyn failed to compile code
- LINQ to SQL multiple tables left outer join
- Entity-framework code is slow when using Include() many times
- The data source does not support server-side data paging
- How are people unit testing code that uses Linq to SQL
- Creating a LINQ select from multiple tables
- Entity Framework, Code First and Full Text Search
- Displaying related data from the same table
- UWP setting a ComboBox's SelectedItem when the ItemSource is LINQ
- Linq to remove duplicates in ASP.NET WEB API in unconventional way
- How to check if any word in my List<string> contains in text
- Is there an easy way to group an EF ResultSet into a new object?
- Force Take() to get less than count if there are no enough elements
- How can i Select many with contains in LINQ?
- Why is this Cross Join so Slow in Linq?
- Joining two a ViewModel
- Retrieving the row index of row pulled from datatable useing Linq
- Order IEnumerable by occurrences
- how to implement Linq to Entities IQueryable TakeWhile() functionality
- Linq SQL FirstOrDefault
- Possible to update a row without pulling down and updating every column?
- Calculating Average with Linq
- Split String with Custom conditions and delimeters
- Data class public properties to Dictionary
- When is OnValidate called in Linq?
- LINQ group by then order groups of result
- Combining LINQ Queries to reduce database calls