[Solved] Group by a nested list of object based on date [closed]

var temp = dbconnect.tblAnswerLists .Where(i => i.StudentNum == studentNumber && i.username==objstu.Return_SupervisorUserName_By_StudentNumber(studentNumber)) .ToList() // <– This will bring the data into memory. .Select(i => new PresentClass.supervisorAnswerQuesttionPres { answerList = Return_Answer_List(studentNumber,i.dateOfAnswer.Value.Date), questionList = Return_Question_List(studentNumber, i.dateOfAnswer.Value.Date), date = ConvertToPersianToShow(i.dateOfAnswer.Value.Date) }) .GroupBy(i => i.date) .OrderByDescending(i => i.Key) .ToList(); temp will actually be of type List<IGrouping<string, PresentClass.supervisorAnswerQuesttionPres>>. 2 solved Group … Read more

[Solved] change method code at run time [closed]

My advise: A code at run time cannot be editted! Specially when you’re running the code and a client is using the service. You can edit the code by yourself only. Client would be using if else block statements only. You can edit the code, and add some if else blocks to it, so that … Read more

[Solved] Delete query to delete data from multiple tables in sql server and c#

Like this? It seems easiest just to do it as three separate statements. DELETE FROM Products WHERE SubCatId IN (SELECT SubCatID FROM SubCategory WHERE MainCatId = @mainCatId); DELETE FROM SubCategory WHERE MainCatId = @mainCatId; DELETE FROM MainCategory WHERE MainCatId = @mainCatId; 8 solved Delete query to delete data from multiple tables in sql server and … Read more

[Solved] Upload file using file path as string in c#

File-handling is all fairly new to me but, this is how I’ve done it in a recent MVC project. ImageController: this is how I’m saving the file public ActionResult Create(FormCollection collection) { if (ModelState.IsValid) { HttpPostedFileBase file = Request.Files[“userUploadedFile”]; var userName = User.Identity.Name; var selectAlbum = Request.Form[“lstAlbums”]; Image img = new Image(); img.FileName = file.FileName; … Read more

[Solved] how to convert decimal value into int in c# [closed]

As per your requirement, round decimal up to 2 place using following way : 1) Use Math.Round(). var vatprice= Convert.ToDecimal(Math.Round(dt.Rows[0][5], 2)); 2) second way is var vatprice=Convert.ToDecimal(dt.Rows[0][5].ToString (“#.##”)); solved how to convert decimal value into int in c# [closed]

[Solved] How to write out an hr tag programatically in .net [closed]

You can use a Literal control and set it to PassThrough mode. This is the easiest way for the hr tag Literal myTag = new Literal {Mode = LiteralMode.PassThrough, Text = “<hr/>”}; You can find more information here If you are creating an h1 tag then you should use this HtmlContainerControl myTag = (HtmlContainerControl)new HtmlGenericControl(“h1”); … Read more

[Solved] Find and replace dynamic values via for loop

I think this is what you want, List<string> keys = new List<string>() { “name”, “age”, “param3” }; string url = “http://www.test.com/test.aspx?testinfo=&|&;”; Regex reg = new Regex(“&”); int count = url.Count(p => p == ‘&’); for (int i = 0; i < count; i++) { if (i >= keys.Count) break; url = reg.Replace(url, keys[i], 1); } … Read more

[Solved] add class in master page(code behind) using child page in asp and c# [closed]

FindControl is only able to find server-side controls, not plain HTML tags. In your case it means that you should add attribute runat=”server” to the ClientTab div: <li> <a href=”https://stackoverflow.com/questions/17292020/Clients.aspx”> <div id=”ClientTab” class=”MainNavigationContainerItem” runat=”server”> Client</div> </a> </li> However your code seems to add yet another class tag to this control, which might not be what … Read more

[Solved] Need help understanding this code in a tutorial

PlayingCard: class PlayingCard // **Data Access Layer?** This looks like a business model, nothing to do with data access. In fact, I don’t see any data persistence (like a database) being used in the code at all, so this application doesn’t have a data access layer. private readonly Suit suit; // **readonly to protect from … Read more

[Solved] Help me, throwing exception error in decoding code. help needed

You haven’t said what error you’re getting, but surely your second code should simply be: return Encoding.UTF8.GetString(Convert.FromBase64String(data)); You don’t need to create a new UTF8Encoding You don’t need to worry about decoders explicitly Additionally, your exception handling is nasty – the stack trace would already show where the error occurs, but by catching it and … Read more

[Solved] Throws Security Exception on server , runs on localhost

it’s getting cause of server security level limitation, you need to fixed this in your Web.Config file. or you can asked to Serve Vendor to change the Security Level for your Host. <system.web> <securityPolicy> <trustLevel name=”Full/High/Medium/Low/Minimal” policyFile=”internal”/> </securityPolicy> </system.web> See the Reference Here 2 solved Throws Security Exception on server , runs on localhost

[Solved] Operator ‘+’ cannot be applied to operands of type ‘string’ and ‘void’ C# WebMethod

HttpContext.Current.Response.Redirect doesn’t return a string. I suppose you wanted to do: “<br /><a href=”https://stackoverflow.com/questions/63356491/CS_Activation.aspx?ActivationCode=”>Click here to change your password.</a>”; solved Operator ‘+’ cannot be applied to operands of type ‘string’ and ‘void’ C# WebMethod