namevaluecollection

Bind NameValueCollection to GridView?

What kind of collection I should use to convert NameValue collection to be bindable to GridView? When doing directly it didn't work. Code in aspx.cs private void BindList(NameValueCollection nvpList) { resultGV.DataSource = list; resultGV.DataBind(); } Code in aspx <asp:GridView ID="resultGV" runat="server" AutoGener...

Make NameValueCollection accessible to LINQ Query

How to make NameValueCollection accessible to LINQ query operator such as where, join, groupby? I tried the below: private NameValueCollection RequestFields() { NameValueCollection nvc = new NameValueCollection() { {"emailOption: blah Blah", "true"}, ...

Is there any easy way to sort NameValueCollection on the basis of key in C#?

I am looking for an easy way to sort NameValueCollection on the basis of key - it should not be a performance heavy though. ...

Populate array of objects from namevaluecollection in c#

I am new to C#. Here is a hard-coded thing I got working: InputProperty grantNumber = new InputProperty(); grantNumber.Name = "udf:Grant Number"; grantNumber.Val = "571-1238"; Update update = new Update(); update.Items = new InputProperty[] { grantNumber }; Now I want to generalize this to support an indefinite number of items in the...

Efficient searching of NameValueCollection

Is there a way to pull out keys from a NameValueCollection that pertain to a certain pattern/naming convention without having to iterate through every value in the collection? ...

XML serialization of a collection in C#

I have two classes as follows: public class Info { [XmlAttribute] public string language; public int version; public Book book; public Info() { } public Info(string l, int v, string author, int quantity, int price) { this.language = l; this.version = v; b...

Insert into NameValueCollection in .NET

Is it possible to insert an item into a NameValueCollection in a specific index? I don't see an Insert() method. ...

Accessing System.Collections.Specialized.NameValueCollection in Silverlight v3

Hi, I can see that the system reference is added in silverlight project in visual studio. The assembly is mapped to C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\system.dll. The namespace System.Collections.Specialized does not seem to have NameValueCollection class defined. My issue is that i need to wr...

Modifying config sections in App.config either at runtime or install time.

I have an WinForms application that is deployed using Visual Studio 2008's publish (ClickOnce) system. Within the application's app.config file I have a config section that is required by a third party component that has the form: <section name="thirdPartySection" type="System.Configuration.NameValueSectionHandler" /> The section is t...

What happens behind the scenes during deserialization of a NameValueCollection?

What's going on behind the scenes in .NET (de)serialization that makes it behave the way it does in the following scenario? (This is a test app that just illustrates my setup.) I have a class with a NameValueCollection property: [Serializable] public class MyClassWithNVC { public NameValueCollection NVC { get; set; } } It, in tur...

Sort NameValueCollection against Enum

I have to sort a namevaluecollection(Items usually 5 to 15) Against an enum(having items more than 60). Right now I am using this extension function, Anyone have better idea to write this code.... public static NameValueCollection Sort(this NameValueCollection queryString, Type orderByEnumType, bool excludeZeroValues) { ...

Can't resolve NameValueCollection with Autofac

I am using Autofac 2.1.12 to handle my dependency injection, and am having trouble with one specific issue. I can't seem to resolve a NameValueCollection dependency. Consider the following code snippet: class Foo { public Foo(NameValueCollection collection) { } } static class Run { public static void Main() { var b...

ASP.Net and NameValueCollection

Hello, I have the following method: public object[] GetEventsByUser(DateTime start, DateTime end, string fullUrl) The value of the fullUrl is: http://localhost:50435/page/view.aspx?si=00&amp;us=admin&amp;ut=smt&amp; When I do: NameValueCollection qscoll = HttpUtility.ParseQueryString(fullUrl); I get: {http%3a%2f%2flocalhost%3a5...

Reverse function of HttpUtility.ParseQueryString

.Net's System.Web.HttpUtility class defines the following function to parse a query string into a NameValueCollection: public static NameValueCollection ParseQueryString(string query); Is there any function to do the reverse (i.e. to convert a NameValueCollection into a query string)? ...

Can a freemarker interpolation contain an interpolation?

Let's say I have Freemarker variable A that contains the name of another variable on the hash tree, say. "B." I'd like to use a to read the value of B so, for example, if B contained "C" I could tell Freemarker to output C using A: ${${A}} should result in the output of "C". Naturally, this doesn't work in Freemarker, but is there a way ...

NameValueCollection vs Dictionary<string,string>

Possible Duplicate: IDictionary<string, string> or NameValueCollection Any reason I should use Dictionary<string,string> instead of NameValueCollection? (in C# / .NET Framework) Option 1, using NameValueCollection: //enter values: NameValueCollection nvc = new NameValueCollection() { {"key1", "value1"}, {"key2", "value2...

NameValueCollection doesn't actually do anything with its IEqualityComparer?

I am looking at System.Collections.Specialized.NameValueCollection and it takes an IEqualityComparer, which is good news if someone like me wanted to sort the items in the collection by, say, something like the alphabetical order of the keys. But, on a closer look in Reflector, I don't see the NVC class actually using the IEqualityCompa...

Does this copy the reference or the object?

Sorry, I am being both thick and lazy, but mostly lazy. Actually, not even that. I am trying to save time so I can do more in less time as there's a lot to be done. Does this copy the reference or the actual object data? public class Foo { private NameValueCollection _nvc = null; public Foo( NameValueCollection nvc) { ...

Getting a Request.Headers value

Very simple I'm sure, but driving me up the wall! There is a component that I use in my web application that identifies itself during a web request by adding the header "XYZComponent=true" - the problem I'm having is, how do you check for this in your view? The following wont work: if (Request.Headers["XYZComponent"].Count() > 0) Nor...

AppSettings fallback/default value?

ASP.NET For each appSetting I use, I want to specify a value that will be returned if the specified key isn't found in the appSettings. I was about to create a class to manage this, but I'm thinking this functionality is probably already in the .NET Framework somewhere? Is there a NameValueCollection/Hash/etc-type class in .NET that w...