-
Feb 3rd, 2009, 05:44 AM
#1
Thread Starter
Addicted Member
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
Failing to plan is Planning to fail
-
Feb 3rd, 2009, 07:10 AM
#2
Fanatic Member
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
-
Feb 3rd, 2009, 08:00 AM
#3
Thread Starter
Addicted Member
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
Failing to plan is Planning to fail
-
Feb 4th, 2009, 12:34 AM
#4
Thread Starter
Addicted Member
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.
Failing to plan is Planning to fail
-
Feb 4th, 2009, 02:59 AM
#5
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?
-
Feb 4th, 2009, 03:03 AM
#6
Fanatic Member
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.
-
Feb 4th, 2009, 03:26 AM
#7
Thread Starter
Addicted Member
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.
Failing to plan is Planning to fail
-
Feb 4th, 2009, 03:29 AM
#8
Fanatic Member
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.
-
Feb 4th, 2009, 04:32 PM
#9
Re: How retrieve data from hash table output
Threads merged. Please don't double post or cross post... there's no point.
-
Feb 4th, 2009, 04:32 PM
#10
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.
-
Jul 31st, 2012, 01:44 AM
#11
New Member
Re: How read a hash table object
IDictionaryEnumerator s = hashtable.GetEnumerator();
while (s.MoveNext())
{
MessageBox.Show(s.Key + s.Value.ToString());
}
-
Jul 31st, 2012, 01:49 AM
#12
Re: How read a hash table object
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|