[Solved] how do i use a class without instantiating it?

i would like to use it like this string role = GetRole.OfUser(username); So do so; that appears to be correct. Did you try it? or like this even better: string role = GetRole(username); That won’t work; you have to specify the method you’re calling as well as what class it comes from. If you had … Read more

[Solved] How to format [decimal?] when it’s null? [closed]

You can’t format when it’s null; hopefully the reasons why are obvious. You need to check for the value first: string formattedValue; if (partData.FW_Step.HasValue) formattedValue = partData.FW_Step.Value.ToString(“F3”); else formattedValue = “default value for null”; You can make this code shorter using a ternary expression: string formattedValue = partData.FW_Step.HasValue ? partData.FW_Step.Value.ToString(“F3”) : “default value for null”; … Read more

[Solved] ASP.NET: How to create a search function just using a textbox? [closed]

Since you didn’t provide any code here and asked for the directions, so here you go. Lets assume your TextBox name is ‘textBox1‘ and there is some button beside it. On the click event of that button you should be querying your database for the customer names that matches the text inside your ‘textBox1‘. The … Read more

[Solved] Asp.net foreach loop [closed]

Let me explain what foreach actually does. It iterates over a collection of elements inside an IEnumerable, in order, without skipping anything, even if the current element has the value null. If you have an array with [5,2,24], the elements will be called in oder 5, 2, 24 and will stop after that. 5 solved … Read more

[Solved] why web.config has predefined tags? [closed]

Web.Config itself is written in XML format right? Yes, but in addition to that it has an XML schema associated and the Configuration class which is responsible to read values from this XML file verifies that the schema is being respected. You should make the distinction between well formed XML and valid XML according to … Read more

[Solved] C# ASP.NET for loop issue [closed]

Do something like for(int i=0; i< GroupOfPeople.Count; i++) { GroupOfPeople nm = (GroupOfPeople) nm.GroupOfPeople[i]; if(i < GroupOfPeople.Count – 1) names += nm.FirstName + “, “; else names += ” and ” + nm.FirstName; } solved C# ASP.NET for loop issue [closed]

[Solved] Regex to match given string filenames in a string

This one should work exactly for first two files, but won’t work if there any additional special characters in file names: using System; using System.Collections.Generic; using System.Text.RegularExpressions; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { const string example = “PrintFileURL(\”13572_IndividualInformationReportDelta_2012-06-29_033352.zip\”,\”13572_IndividualInformationReportDelta_2012-06-29_033352.zip\”,0,\”53147\”,\”Jun 29 3:33\”,\”/icons/default.gif\”)”; Console.WriteLine(example); const string pattern = “\\\”([a-zA-Z0-9\\-_]*?\\..*?)\\\””; var regex = new … Read more

[Solved] how to download gridview in excel in ASP.NET C #, ie How to use group by in datatable

Ugh, be prepared for an accident that makes a mess of your data with this “associated by position” idea I wouldn’t use LINQ for this either var l = new List<string>(); string prev = null; foreach(DataRow r in dt.Rows){ var s = (string)r[“Column1”]; var t = (string)r[“Column2”]; if(s != prev){ l.Add(s); prev = s; } … Read more

[Solved] Index and length must refer to a location within the string ASP.NET [duplicate]

I think you are looking for String.Insert Returns a new string in which a specified string is inserted at a specified index position in this instance. So simply use return name.Insert(extPos, “_180x140”); However as per your error is concerned use return name.Substring(0, extPos) + “_180x140” + name.Substring(extPos); solved Index and length must refer to a … Read more