i am curious to know can we pass column name dynamically for where clause.
see a screen shot for searching grid. here is my link [^]
i just got a sample query. please tell me does it work?
public ActionResult Index(String ColumnName,String SearchText)
private CustomersEntities db = new CustomersEntities();
var customer = (from s in db.Customers
CustomerID = s.CustomerID,
CompanyName = s.CompanyName,
ContactName = s.ContactName,
ContactTitle = s.ContactTitle,
Address = s.Address
.Where(s => s.Field<string>(ColumnName).ToUpper().Contains(SearchText.ToUpper());
most of the time i mention column name when search with EF like this way
var query = from s in db.Customers select s;
if (ColumnName == "CompanyName")
query = query.Where(c => c.CompanyName == SearchText);
elseif (ColumnName == "ContactName")
query = query.Where(c => c.ContactName == SearchText);
see my screen shot link then you can understand what kind of UI i have to develop. user will select column name from dropdown and put value for search textbox. so when user will hint search button then search need to be done on selected column name. i may have 100 column names in dropdown and it will be huge code if i do it with if..else fashion as i mention here with sample code.
so tell me how could i reduce code for searching where column name will be passed.
...the AsEnumerable<TSource> method can be used to hide the custom methods and instead make the standard query operators available.
So, in your snippet the coder wants to make sure that the IEnumerable.Select method is called rather than any other method named "Select" on the object. This is generally to provide compile-time safety to code where ambiguities might crop up. You see this sort of sanity check a lot in code that will accept dynamics or generics.
As to your second question: always use ToArray() for immutable collections. It has less overhead and is generally more efficient if you're providing collections that won't be modified (add or remove items) later within your application.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("hsc2");
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference(FileUpload1.FileName);
//...Create or overwrite the "myblob" blob with contents from a local file.
using (var memoryStream = new MemoryStream())
memoryStream.Position = 0;
StreamReader streamReader = new StreamReader(memoryStream);
//String blobText = streamReader.ReadToEnd();
DataSet ds1 = new DataSet();
I am trying to open a csv file and do some formatting.
Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click
Dim myexcel As New Excel.Application
Dim myworkbook As Excel.Workbook
Dim foldername As String
foldername = "C:\SplitFiles\"
Dim path1 As String
Dim path2 As String()
If Directory.Exists(foldername) Then path2 = Directory.GetFiles(foldername)
For Each path1 In path2
If File.Exists(path1) Then
myworkbook = myexcel.Workbooks.Open(path1, Format:=6, Delimiter:=",", Editable:=True)
Just that when the workbook.open(path1) is executed. it wouldn't open the file. I have to open the file and make it active workbook and active sheet and have to do some formatting on the worksheet. then save and close.
the directory has around 40 files which will have similar formatting to be done.
You've posted this in the ASP.NET forum. Office Interop doesn't work in ASP.NET; neither does MsgBox.
They might appear to work when you're debugging the code in Visual Studio. But that's only because the client and server are the same computer in that instance.
As soon as you deploy your code to a real server, the MsgBox call will either crash, or cause your code to hang waiting for someone to log in to the server and dismiss the hundreds of hidden message boxes, and then close the hundreds of hidden instances of Excel.
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you want to open a file on the client, then you need to write it to the response. And to pre-empt your next question: no, you can't force the user to open it, or to save it to a specific location.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Hi. I am currently working on product where I need to host couple of videos which are paid contents. I have no exact idea what could be best approach to do this. Where can we host these contents and provide access to paid users? Do we need seperate video hosting or this can be hosted on IIS folders itself?
Does anyone have any good suggestion? Appreciate any help, thank you.
I have received an ASP.Net MVC application from a colleague that I have to start working on, it had different dll reference errors when it was given, at that time it was showing me errors in the errors list, after adding the dlls when I compiled the Orange sign on the dlls is gone but when I compile the application it says build failed as below:
Rebuild All: 3 succeeded, 1 failed, 0 skipped
But its not giving me any details about the error in the error window. I could able to build all other assemblies individually by unloading the UI application, then added UI application still it gives me failed and doesn't display the details of the error in the error Window.
Here are the Warnings I am getting, any help would be very helpful - thanks in advance friends.
Warning 3 Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="log4net" culture="neutral" publicKeyToken="669e0ddf0bb1aa2a" /><bindingRedirect oldVersion="0.0.0.0-18.104.22.168" newVersion="22.214.171.124" /></dependentAssembly></assemblyBinding> XXXXX.SUD.CRS.Services (XXXXX.SUD.CRS.Services\XXXXX.SUD.CRS.Services)
"There is already enough hatred in the world lets spread love, compassion and affection."
Hi, we do a lot with asp.net pages accessing our sql servers and using gridviews which works out good for a bringing back lists and even have images incorporated in those views but looking for way to show more like a lot of shopping sites where might have multiple boxes going across with maybe item desc, price, image, add to cart button and maybe more details. So might have like 4-6 boxes across then multiple rows. Hoping to be able to make dynamic based on sql data. Don't think gridviews will work but looking for any suggestions or examples. We do mostly vb.net so that would help for example. Thanks.