I have the object property StockContract.Dictionary which is a dictionary
collection of <string, stringkey/value pairs. I need to be able to
retreive the keys and their values and display them on a page. I want to use
something like a repeater or something like that. I don't know if this would
be code I will have to manually write myself, or if it can be done with
dataBinding of some sort. I am using vs2008 and c# 3.5. Any ideas on how to
do something like this? 8 1962
"Andy B" <a_*****@sbcglobal.netwrote in message
news:Ov**************@TK2MSFTNGP03.phx.gbl...
>I have the object property StockContract.Dictionary which is a dictionary collection of <string, stringkey/value pairs. I need to be able to retreive the keys and their values and display them on a page. I want to use something like a repeater or something like that. I don't know if this would be code I will have to manually write myself, or if it can be done with dataBinding of some sort. I am using vs2008 and c# 3.5. Any ideas on how to do something like this?
<asp:GridView ID="gvTest" runat="server" AutoGenerateColumns="true" />
Dictionary<string, stringdicTest = new Dictionary<string, string>();
dicTest.Add("1st", "First");
dicTest.Add("2nd", "Second");
dicTest.Add("3rd", "Third");
gvTest.DataSource = dicTest;
gvTest.DataBind();
--
Mark Rae
ASP.NET MVP http://www.markrae.net
I tried to put the StockContract.Dictionary property as a
listView.DataSource. The compiler isn't complaining about it yet, but there
is another question about this kind of databinding. Inside the item
template, What do I use for the Eval() method to get the values out of the
Dictionary collection? I tried Eval("Keys") as the text for a Label control,
but that is what I litterally end up with as the text instead of the text of
the key. Any ideas how to deal with something like this?
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Andy B" <a_*****@sbcglobal.netwrote in message
news:Ov**************@TK2MSFTNGP03.phx.gbl...
>>I have the object property StockContract.Dictionary which is a dictionary collection of <string, stringkey/value pairs. I need to be able to retreive the keys and their values and display them on a page. I want to use something like a repeater or something like that. I don't know if this would be code I will have to manually write myself, or if it can be done with dataBinding of some sort. I am using vs2008 and c# 3.5. Any ideas on how to do something like this?
<asp:GridView ID="gvTest" runat="server" AutoGenerateColumns="true" />
Dictionary<string, stringdicTest = new Dictionary<string, string>();
dicTest.Add("1st", "First");
dicTest.Add("2nd", "Second");
dicTest.Add("3rd", "Third");
gvTest.DataSource = dicTest;
gvTest.DataBind();
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"Andy B" <a_*****@sbcglobal.netwrote in message
news:ub**************@TK2MSFTNGP03.phx.gbl...
[top-posting corrected]
>>>I have the object property StockContract.Dictionary which is a dictionary collection of <string, stringkey/value pairs. I need to be able to retreive the keys and their values and display them on a page. I want to use something like a repeater or something like that. I don't know if this would be code I will have to manually write myself, or if it can be done with dataBinding of some sort. I am using vs2008 and c# 3.5. Any ideas on how to do something like this?
<asp:GridView ID="gvTest" runat="server" AutoGenerateColumns="true" />
Dictionary<string, stringdicTest = new Dictionary<string, string>(); dicTest.Add("1st", "First"); dicTest.Add("2nd", "Second"); dicTest.Add("3rd", "Third"); gvTest.DataSource = dicTest; gvTest.DataBind();
I tried to put the StockContract.Dictionary property as a
listView.DataSource. The compiler isn't complaining about it yet, but
there is another question about this kind of databinding. Inside the item
template, What do I use for the Eval() method to get the values out of the
Dictionary collection? I tried Eval("Keys") as the text for a Label
control, but that is what I litterally end up with as the text instead of
the text of the key. Any ideas how to deal with something like this?
Not sure what you're trying to do exactly...
What you've got here is, essentially, a two-dimensional array - which field
from which row are you trying to use as the text in a Label control...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
I am trying to databind to the collection like you normally would say to a
database table. I need to cycle through all of the keys and print out their
key text and value text on a page. The print out has to be formatted with
html markup...
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:O%****************@TK2MSFTNGP03.phx.gbl...
"Andy B" <a_*****@sbcglobal.netwrote in message
news:ub**************@TK2MSFTNGP03.phx.gbl...
[top-posting corrected]
>>>>I have the object property StockContract.Dictionary which is a dictionary collection of <string, stringkey/value pairs. I need to be able to retreive the keys and their values and display them on a page. I want to use something like a repeater or something like that. I don't know if this would be code I will have to manually write myself, or if it can be done with dataBinding of some sort. I am using vs2008 and c# 3.5. Any ideas on how to do something like this?
<asp:GridView ID="gvTest" runat="server" AutoGenerateColumns="true" />
Dictionary<string, stringdicTest = new Dictionary<string, string>(); dicTest.Add("1st", "First"); dicTest.Add("2nd", "Second"); dicTest.Add("3rd", "Third"); gvTest.DataSource = dicTest; gvTest.DataBind();
I tried to put the StockContract.Dictionary property as a listView.DataSource. The compiler isn't complaining about it yet, but there is another question about this kind of databinding. Inside the item template, What do I use for the Eval() method to get the values out of the Dictionary collection? I tried Eval("Keys") as the text for a Label control, but that is what I litterally end up with as the text instead of the text of the key. Any ideas how to deal with something like this?
Not sure what you're trying to do exactly...
What you've got here is, essentially, a two-dimensional array - which
field from which row are you trying to use as the text in a Label
control...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"Andy B" <a_*****@sbcglobal.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
[top-posting corrected again]
>>>>>I have the object property StockContract.Dictionary which is a >dictionary collection of <string, stringkey/value pairs. I need to be >able to retreive the keys and their values and display them on a page. >I want to use something like a repeater or something like that. I don't >know if this would be code I will have to manually write myself, or if >it can be done with dataBinding of some sort. I am using vs2008 and c# >3.5. Any ideas on how to do something like this?
<asp:GridView ID="gvTest" runat="server" AutoGenerateColumns="true" />
Dictionary<string, stringdicTest = new Dictionary<string, string>(); dicTest.Add("1st", "First"); dicTest.Add("2nd", "Second"); dicTest.Add("3rd", "Third"); gvTest.DataSource = dicTest; gvTest.DataBind();
I tried to put the StockContract.Dictionary property as a listView.DataSource. The compiler isn't complaining about it yet, but there is another question about this kind of databinding. Inside the item template, What do I use for the Eval() method to get the values out of the Dictionary collection? I tried Eval("Keys") as the text for a Label control, but that is what I litterally end up with as the text instead of the text of the key. Any ideas how to deal with something like this?
Not sure what you're trying to do exactly...
What you've got here is, essentially, a two-dimensional array - which field from which row are you trying to use as the text in a Label control...?
I am trying to databind to the collection like you normally would say to a database table.
Can you clarify what you mean by that, please? You don't databind *to* a
database table - you databind *from* a database table *to* a webcontrol such
as a GridView etc...
I need to cycle through all of the keys and print out their key text and
value text on a page. The print out has to be formatted with html
markup...
You didn't say that originally...
foreach (KeyValuePair<string, stringobjKVP in dicTest)
{
MyLabel.Text += objKVP.Key + " - " + objKVP.Value + "<br />";
}
If the Dictionary is quite large, it would probably be better to use a
StringBuilder...
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uo**************@TK2MSFTNGP04.phx.gbl...
"Andy B" <a_*****@sbcglobal.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
[top-posting corrected again]
>>>>>>I have the object property StockContract.Dictionary which is a >>dictionary collection of <string, stringkey/value pairs. I need to >>be able to retreive the keys and their values and display them on a >>page. I want to use something like a repeater or something like that. >>I don't know if this would be code I will have to manually write >>myself, or if it can be done with dataBinding of some sort. I am using >>vs2008 and c# 3.5. Any ideas on how to do something like this? > <asp:GridView ID="gvTest" runat="server" AutoGenerateColumns="true" /> > Dictionary<string, stringdicTest = new Dictionary<string, string>(); dicTest.Add("1st", "First"); dicTest.Add("2nd", "Second"); dicTest.Add("3rd", "Third"); gvTest.DataSource = dicTest; gvTest.DataBind();
I tried to put the StockContract.Dictionary property as a listView.DataSource. The compiler isn't complaining about it yet, but there is another question about this kind of databinding. Inside the item template, What do I use for the Eval() method to get the values out of the Dictionary collection? I tried Eval("Keys") as the text for a Label control, but that is what I litterally end up with as the text instead of the text of the key. Any ideas how to deal with something like this?
Not sure what you're trying to do exactly...
What you've got here is, essentially, a two-dimensional array - which field from which row are you trying to use as the text in a Label control...?
I am trying to databind to the collection like you normally would say to a database table.
Can you clarify what you mean by that, please? You don't databind *to* a
database table - you databind *from* a database table *to* a webcontrol
such as a GridView etc...
>I need to cycle through all of the keys and print out their key text and value text on a page. The print out has to be formatted with html markup...
You didn't say that originally...
foreach (KeyValuePair<string, stringobjKVP in dicTest)
{
MyLabel.Text += objKVP.Key + " - " + objKVP.Value + "<br />";
}
If the Dictionary is quite large, it would probably be better to use a
StringBuilder...
--
Mark Rae
ASP.NET MVP http://www.markrae.net
There seems to be a problem with the KeyValuePair<string, stringpart. I am
not getting intelisense for the local variable defined as a KeyValuePair.
foreach(KeyValuePair<string, stringvalues in StockContract.Dictionary) {
Label1.Text = Values.key; //cant get intelisense for this line...
....
}
"Andy B" <a_*****@sbcglobal.netwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
There seems to be a problem with the KeyValuePair<string, stringpart. I
am not getting intelisense for the local variable defined as a
KeyValuePair.
foreach(KeyValuePair<string, stringvalues in StockContract.Dictionary) {
Label1.Text = Values.key; //cant get intelisense for this line...
C# is case-sensitive - Values.key is not the same as values.Key...
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Hi Andy,
I was just trying to do this myself, and had some luck using the
ItemDataBound event:
MyRepeater.DataSource = dicTest;
rptBusinessTypes.ItemDataBound += new
RepeaterItemEventHandler(MyRepeater_ItemDataBound) ;
MyRepeater.DataBind();
void MyRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e){
//in the repeater ItemTemplate, you'll have a control
//called foo. I made mine an asp:Hyperlink.
HyperLink foo = e.Item.FindControl("foo") as HyperLink;
if(null != foo)
{
DictionaryEntry de = (DictionaryEntry)(e.Item.DataItem);
foo.Text = Convert.ToString(de.Value);
}
*** Sent via Developersdex http://www.developersdex.com *** This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rodd Snook |
last post by:
I have an application which makes extensive use of the
Scripting.Dictionary object. I'm not doing anything silly like putting
them outside the page scope -- just creating quite a few of them and...
|
by: boohoo |
last post by:
I can't seem to do this:
I want to take a query string and place two halves of the querystring
into two separate dictionary objects.
So... I loop through the collection of querystring items,...
|
by: Pavils Jurjans |
last post by:
Hello,
There's some confusion about the purpose and difference between these handy
classes...
First, both of them are holding number of key - value pairs, right? Then, I
see that there may be...
|
by: Kathy Burke |
last post by:
HI. in asp.net app, I have an xmlDocument that I transform to the client
html. Using xsl I create a few textboxes to capture user input. Each of
these are related to <data> elements in the xmlDoc....
|
by: RAJ |
last post by:
In our multi-tier application, we have several ASP.NET user controls which
will update the same data source provided by middle tier logic.
In this particular scenario we have one user control...
|
by: Diffident |
last post by:
Hello All,
I want to display all the name-value pairs of the session object....how can
I print them out? i.e., suppose once a user logs in I set a session variable
login time Session = "2pm" and...
|
by: Andrew Robinson |
last post by:
I need to serialize a dictionary so I can encode the contents. I have the
following working but the size seems large. I am guessing that I am
serializing the entire object not just the data. Is...
|
by: Charles Krug |
last post by:
List,
I'd like to do the following with Tkinter's Frame() object:
1. Display a collection of pack()-able objects. Easy. Done. I hold
the objects in a dictionary, mostly so that the owning...
|
by: kdotsky |
last post by:
Hello,
I am using some very large dictionaries with keys that are long strings
(urls). For a large dictionary these keys start to take up a
significant amount of memory. I do not need access to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |