How retrieve data from hash table output
Dear Friends,
I got a hash table like below i put
Response Received:
System.Collections.Hashtable
Key: http://www.paypal.com
Value:
System.Collections.Hashtable
Key: reselleraccesslevel
Value:
AllowAll
Key: customerallowedpaymenttype
Value:
AllowAll
Key: gatewayname
Value:
http://www.paypal.com
Key: customeraccesslevel
Value:
AllowAll
Key: paymenttypeid
Value:
25595
Key: displayposition
Value:
1
Now i need to retrieve key and value from the output (ie web browser). Is it possible? I am using Asp.Net 2.0 application. Also i need to bind in grid this key and value.
Hope your's reply.
Thanks & Regards
:)
Re: How retrieve data from hash table output
hi,
You can bind hashtables to gridviews.
For an example, you have a simple hashtable that has all its values as string. You will have to add 2 bound columns for your gridview and set their DataField to the key and value properties of the hash table.
Code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="key" HeaderText="key" />
<asp:BoundField DataField="value" HeaderText="value" />
</Columns>
</asp:GridView>
Then in your code behind you can do standard
GridView1.Datasource = YourHashtable;
GridView1.DataBind();
Good Luck
Re: How retrieve data from hash table output
Hi
Actually i have output like a hash table. I need a value and key only.So how to retrieve the key and value from the output ie web browser. Please reply me as soon as. Hope your's reply.
Thanks & Regards
How read a hash table object
Hi friends,
I am in problem. I am using Asp.Net 2.0 application.I got an output in hash table like
System.Collections.Hashtable
Key: ashok.org
Value:
System.Collections.Hashtable
Key: status
Value:
available
Key: classkey
Value:
domorg
The above hash table output i got it. I want to read this hash table object and i need to get the Key and value both.
I can create hash table object and using IDictionary i can get these Key and Value. But first time i can get Key and write it. Here my Value is in object type and inside I have Key and Value. How can i read the object?? and get the Key and Value inside of Value. Please give me suggestion. Hope yours reply.
Re: How retrieve data from hash table output
I'm not sure I understand... you have the hashtable so all you need to do is bind it and it'll show up in the output. If that's not it, can you explain in more detail?
Re: How read a hash table object
hi, Try the follwoing code. this code shows the key and values also.
Code:
Hashtable exampleTable = new Hashtable();
exampleTable.Add("txt", "notepad.exe");
exampleTable.Add("bmp", "paint.exe");
exampleTable.Add("dib", "paint.exe");
exampleTable.Add("rtf", "wordpad.exe");
foreach (string key in exampleTable.Keys)
{
Response.Write(exampleTable[key].ToString(),key);
}
Good luck.
Re: How retrieve data from hash table output
Hi mendhak,
Thanks for your reply. Actually i have output
system.collections.hashtable
Key: ashok.org
Value :
system.collections.hashtable
Key : status
Value: Available
Key: classkey
Value : demoorg
I can read using dictionaryentry. But what my problem that while i put foreach i got Key as a string next value as an object that is system.collections.hashtable. After that inside i have key and value.How can i get hastable inside of hashtable value both??
This is my question. I think that now you got it my doubt.
Hope your's reply.
Re: How retrieve data from hash table output
hi,
I replied to you. View this post.
http://www.vbforums.com/showthread.php?t=556389
don't Post same threads for two time.
Good luck.
Re: How retrieve data from hash table output
Threads merged. Please don't double post or cross post... there's no point.
Re: How retrieve data from hash table output
For each item that you get, if you know the type inside, then get the value out and cast it or CType() it to the type you want, in your case, that'd be another HashTable. You then use that as a regular Hashtable to read it.
Re: How read a hash table object
IDictionaryEnumerator s = hashtable.GetEnumerator();
while (s.MoveNext())
{
MessageBox.Show(s.Key + s.Value.ToString());
}
Re: How read a hash table object
Quote:
Originally Posted by
prasad.k539
IDictionaryEnumerator s = hashtable.GetEnumerator();
while (s.MoveNext())
{
MessageBox.Show(s.Key + s.Value.ToString());
}
Hello,
Welcome to the forums! Thanks for taking the time to post in this thread!
One thing I would say though, using MessageBox.Show within an ASP.NET application is not really a recommended best practice. Although it will "work" when you are debugging out of Visual Studio, when you deploy the application onto a server, you will never see the MessageBox appear on the client.
Gary