473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Bind NameValueCollection to a DataGrid

Hi,
I have a NameValueCollection, is it possible to bind this object to a
two-column DataGrid? How to match columns?

Thanks!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
Nov 19 '05 #1
4 4019
You have a column named "Key" and one named "Value"

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a NameValueCollection, is it possible to bind this object to a
two-column DataGrid? How to match columns?

Thanks!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy

Nov 19 '05 #2
It seems that it doesn't work:
<asp:DataGrid id="dgServerVariables" runat="server"
AutoGenerateColumns="False">
<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7"
BackColor="#4A3C8C"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="Key" HeaderText="Key"></asp:BoundColumn>
<asp:BoundColumn DataField="Value" HeaderText="Value"></asp:BoundColumn>
</Columns>
</asp:DataGrid>

In code behind:
private void loadServerVariables() {
NameValueCollection coll;

// Load ServerVariable collection into NameValueCollection object.
coll = Request.ServerVariables;

dgServerVariables.DataSource = coll;
dgServerVariables.DataBind();
}

Then I get error:
A field or property with the name 'Key' was not found on the selected
datasource.

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:up**************@TK2MSFTNGP12.phx.gbl...
You have a column named "Key" and one named "Value"

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a NameValueCollection, is it possible to bind this object to a
two-column DataGrid? How to match columns?

Thanks!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy


Nov 19 '05 #3
Learn something every day...only works with hashtables.....
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...
It seems that it doesn't work:
<asp:DataGrid id="dgServerVariables" runat="server"
AutoGenerateColumns="False">
<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7"
BackColor="#4A3C8C"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="Key" HeaderText="Key"></asp:BoundColumn>
<asp:BoundColumn DataField="Value" HeaderText="Value"></asp:BoundColumn>
</Columns>
</asp:DataGrid>

In code behind:
private void loadServerVariables() {
NameValueCollection coll;

// Load ServerVariable collection into NameValueCollection object.
coll = Request.ServerVariables;

dgServerVariables.DataSource = coll;
dgServerVariables.DataBind();
}

Then I get error:
A field or property with the name 'Key' was not found on the selected
datasource.

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:up**************@TK2MSFTNGP12.phx.gbl...
You have a column named "Key" and one named "Value"

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a NameValueCollection, is it possible to bind this object to a
two-column DataGrid? How to match columns?

Thanks!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy



Nov 19 '05 #4
SortedList or classes derived from DictionaryBase should do.

Eliyahu

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:eM**************@TK2MSFTNGP12.phx.gbl...
Learn something every day...only works with hashtables.....
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...
It seems that it doesn't work:
<asp:DataGrid id="dgServerVariables" runat="server"
AutoGenerateColumns="False">
<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7"
BackColor="#4A3C8C"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="Key" HeaderText="Key"></asp:BoundColumn>
<asp:BoundColumn DataField="Value" HeaderText="Value"></asp:BoundColumn> </Columns>
</asp:DataGrid>

In code behind:
private void loadServerVariables() {
NameValueCollection coll;

// Load ServerVariable collection into NameValueCollection object.
coll = Request.ServerVariables;

dgServerVariables.DataSource = coll;
dgServerVariables.DataBind();
}

Then I get error:
A field or property with the name 'Key' was not found on the selected
datasource.

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:up**************@TK2MSFTNGP12.phx.gbl...
You have a column named "Key" and one named "Value"

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a NameValueCollection, is it possible to bind this object to a two-column DataGrid? How to match columns?

Thanks!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy



Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pete Nelson | last post by:
Does anyone know of a way to bind a string collection to a datagrid? Basically, I have an object, CreditPlans, and a string collection, ModelNumbers. I'd like to bind the ModelNumbers collection...
4
by: Greg Linwood | last post by:
I am wondering what the best approach to binding XML data to an asp:Table from the Page_Load event in a code behind module? I'm using VB.Net and initially approached this by adding a table to the...
6
by: coleenholley | last post by:
I have a Class Module written in VB that calls an RPC (written in COBOL) we have written code to read the data from the RPC, and we create a temporary datatable to store the data from the RPC. This...
3
by: AFN | last post by:
I need to manually create the data to be shown in a datagrid (or some data table object). Should I create an array and bind the array to the datagrid OR should I create a temporary dataset and...
1
by: suresh_C# | last post by:
Hi All, I want to bind datagrid with 3 different datatables. Please tell me what is a right way of doing that. Any help will be appreciated. Thanks, Mahesh
2
by: A Traveler | last post by:
Hi, I have a custom collection class i wrote, LineItemsCollection, which is a strongly typed collection of objects of my LineItem class. The LineItem class is a simple class with just a couple...
7
by: Jed | last post by:
I have a web service method that returns an array of custom objects marked serializeable with fully described public properties. When I bind the results to a DataGrid I can access the properties...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
3
by: serge calderara | last post by:
Dear all, Does anyone know how to bind a System.Collection.ArraysList object to a Dataset ? Thanks for your reply Regards Serge
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.