Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Can you use Dictionary&lt;string,string&gt; instead of NameValueCollection. Since Dictionary&lt;T,T&gt; implements IEnumerable you could use LINQ as so:</p> <pre><code>resultGV.DataSource = from item in nvpDictionary select new { Key = item.Key, Value = item.Value }; resultGV.DataBind(); </code></pre> <p>[EDIT] Actually you may be able to use Dictionary directly as:</p> <pre><code>resultGV.DataSource = nvpDictionary; resultGV.DataBind(); </code></pre> <p>If it doesn't map key/value the way you want you can always go back to LINQ. LINQ would also allow you to rename the fields to whatever you want.</p> <p>[EDIT] If you can't change to use Dictionary&lt;T,T&gt;, make a copy of the NameValueCollection as a Dictionary in the method and bind to it.</p> <pre><code>private void BindList(NameValueCollection nvpList) { Dictionary&lt;string,string&gt; temp = new Dictionary&lt;string,string&gt;(); foreach (string key in nvpList) { temp.Add(key,nvpList[key]); } resultGV.DataSource = temp; resultGV.DataBind(); } </code></pre> <p>If you do this a lot, you could write an extension method to convert to a Dictionary, and use it so.</p> <pre><code>public static class NameValueCollectionExtensions { public static Dictionary&lt;string,string&gt; ToDictionary( this NameValueCollection collection ) { Dictionary&lt;string,string&gt; temp = new Dictionary&lt;string,string&gt;(); foreach (string key in collection) { temp.Add(key,collection[key]); } return temp; } } private void BindList(NameValueCollection nvpList) { resultGV.DataSource = nvpList.ToDictionary(); resultGV.DataBind(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload