473,394 Members | 1,778 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,394 software developers and data experts.

NameValueCollection Question

Can an individual value be changed or must the entire collection for a
specific key be cleared and re added?

Bernie.
Nov 16 '05 #1
4 2235
Bernie,

You should just be able to do this:

// pobjNameValueCollection is the NameValueCollection instance.
pobjNameValueCollection["key"] = "new value";

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bernie Walker" <bw*****@buffalo.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
Can an individual value be changed or must the entire collection for a
specific key be cleared and re added?

Bernie.

Nov 16 '05 #2
Bernie,

You should just be able to do this:

// pobjNameValueCollection is the NameValueCollection instance.
pobjNameValueCollection["key"] = "new value";

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bernie Walker" <bw*****@buffalo.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
Can an individual value be changed or must the entire collection for a
specific key be cleared and re added?

Bernie.

Nov 16 '05 #3
Lets say I have:
NameValueCollection nvc = new NameValueCollection():
nvc.Add("Saying","Apples");
nvc.Add("Saying","Peaches");
nvc.Add("Saying","Pumpkin Pie");

now I want to change the value of 'Pumpkin Pie' to 'Cherry Pie' for the key
'Saying'

Is there a way to access the third value of the key and change it?

Bernie.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oq**************@TK2MSFTNGP10.phx.gbl...
Bernie,

You should just be able to do this:

// pobjNameValueCollection is the NameValueCollection instance.
pobjNameValueCollection["key"] = "new value";

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bernie Walker" <bw*****@buffalo.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
Can an individual value be changed or must the entire collection for a
specific key be cleared and re added?

Bernie.


Nov 16 '05 #4
Bernie,

You will have to call GetValues to get the value for the key. Once you
do that, you can replace the value you want, remove the origial values from
the list, and then re-add all the values.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bernie Walker" <bw*****@buffalo.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Lets say I have:
NameValueCollection nvc = new NameValueCollection():
nvc.Add("Saying","Apples");
nvc.Add("Saying","Peaches");
nvc.Add("Saying","Pumpkin Pie");

now I want to change the value of 'Pumpkin Pie' to 'Cherry Pie' for the key 'Saying'

Is there a way to access the third value of the key and change it?

Bernie.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Oq**************@TK2MSFTNGP10.phx.gbl...
Bernie,

You should just be able to do this:

// pobjNameValueCollection is the NameValueCollection instance.
pobjNameValueCollection["key"] = "new value";

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bernie Walker" <bw*****@buffalo.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
Can an individual value be changed or must the entire collection for a
specific key be cleared and re added?

Bernie.



Nov 16 '05 #5

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

Similar topics

7
by: davidw | last post by:
I always use NameValueCollection. But I read an article says the only differece between Hashtable and NameValueCollection is that NameValueCollection could accept more than one value with same key?...
1
by: Mark Miller | last post by:
I just recently started getting the above error on a page I am posting MULTIPART/FORM-DATA. We have SoftArtisans FileUp component and Filter installed on the server in question and up until a day...
0
by: Yuri Vanzine | last post by:
Saw this requested awhile ago on Matthew Reynolds's blog here: http://www.dotnet247.com/247reference/msgs/11/57944.aspx Problem: often times I deal with querystring-formatted strings w/o the...
0
by: Yuri Vanzine | last post by:
Saw this requested awhile ago on Matthew Reynolds's blog here: http://www.dotnet247.com/247reference/msgs/11/57944.aspx Problem: often times I deal with querystring-formatted strings w/o the...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.