PC Review


Reply
Thread Tools Rate Thread

Bind NameValueCollection to a DataGrid

 
 
Hardy Wang
Guest
Posts: n/a
 
      16th Aug 2005
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


 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      16th Aug 2005
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Hardy Wang
Guest
Posts: n/a
 
      16th Aug 2005
It seems that it doesn't work:
<aspataGrid 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>
</aspataGrid>

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:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      16th Aug 2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> It seems that it doesn't work:
> <aspataGrid 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>
> </aspataGrid>
>
> 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:(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> 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
>>>

>>
>>

>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      16th Aug 2005
SortedList or classes derived from DictionaryBase should do.

Eliyahu

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > It seems that it doesn't work:
> > <aspataGrid 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>
> > </aspataGrid>
> >
> > 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:(E-Mail Removed)...
> >> 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" <(E-Mail Removed)> wrote in message
> >> news:%(E-Mail Removed)...
> >>> 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
> >>>
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid Bind to DataSet, then Bind to DaTaview, GOT ERROR...PLS HELP A_PK Microsoft Dot NET Compact Framework 16 13th Apr 2005 04:27 AM
DataGrid Bind to DataSet, then Bind to DaTaview, GOT ERROR...PLS HELP A_PK Microsoft VB .NET 17 13th Apr 2005 04:27 AM
DataGrid bind chora Microsoft Dot NET Compact Framework 3 27th Nov 2004 06:44 PM
Bind DataGrid on the client =?Utf-8?B?TWFyaw==?= Microsoft ASP .NET 2 13th Feb 2004 09:31 PM
Bind ADOMD to Datagrid Wisam Microsoft ADO .NET 0 9th Dec 2003 05:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:49 AM.