473,949 Members | 22,282 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Array values from hashtable?

Hello,

I'm working on a ASP.NET/C# school project and I'm having some
difficulties. I'm trying to extract the values of an array, and print
them to my screen. I've added the array to a hashtable. I know how to
extract something like a string, so that isn't the problem. Can
someone help me?

Sourcecode:

using System;
using System.Collecti ons;
using System.Configur ation;
using System.Data;
using System.Data.Sql Client;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using System.Text.Reg ularExpressions ;

namespace Gorden.Multiple {

public class MyCodeBehind : Page {

public string strInput;
public string strOutput;

public void Page_Load(objec t sender, System.EventArg s e) {

if(!IsPostBack) {

DataSet myDataSet = new DataSet();

SqlConnection myConnection = new
SqlConnection(C onfigurationSet tings.AppSettin gs.Get("connect ionstring"));

SqlDataAdapter myData = new SqlDataAdapter( "SELECT [ID],
[Naam] FROM [Categorie]", myConnection);

myConnection.Op en();

myData.Fill(myD ataSet, "Input");

int intRows = myDataSet.Table s["Input"].Rows.Count;
int intColumns = myDataSet.Table s["Input"].Columns.Count;
Hashtable myTable = new Hashtable();

string [,] myArray = new string [intColumns,intC olumns];

int i = 0;
int j = 0;

foreach (DataRow myRow in myDataSet.Table s["Input"].Rows)
{
string strIdentifier = myRow[0].ToString();
foreach (DataColumn myCol in
myDataSet.Table s["Input"].Columns){
string strValue = myRow[myCol].ToString();
string strKey = myCol.ToString( );

if(i <= intColumns - 1) {
myArray [i,j] = strKey;
j++;
myArray [i,j] = strValue;
i++;
j = 0;
}

if(i == intColumns) {
myTable.Add(str Identifier, myArray);
System.Array.Cl ear(myArray, 0, intColumns -
1);
i=0;
j=0;
}
}
}
vullen(myTable) ;

}
}

public void inlezen() {

strInput = null;
StreamReader srRead = File.OpenText(" D:\\product\\me nu.tpl");
srRead.BaseStre am.Seek(0, SeekOrigin.Begi n);
strInput = srRead.ReadToEn d();
srRead.Close();
}

public void vullen(Hashtabl e aTable) {

Do something to get values of the array......
}

protected override void Render(HtmlText Writer writer) {

writer.Write(st rOutput);
}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e) {
InitializeCompo nent();
base.OnInit(e);
}

private void InitializeCompo nent() {
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
}
}
Nov 15 '05 #1
0 1223

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

Similar topics

31
4564
by: Alexis Nikichine | last post by:
Hello, It is common knowledge that arrays can be used as hashtables: var color = ; color = 0xFF0000; color = 0x0000FF;
38
5275
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please let's us do not go into an "each dot over i" clarification discussion now - however you want to call - you call it ;-) array contains records of all files in the current dir. array contains records of all subs in the current dir
9
2270
by: Arjen | last post by:
Hello, Persons is a hashtable which I convert to an array. Person aPerson = new Person; Persons.Values.CopyTo( aPerson, 0 ); Now I can access the person items like aPerson.name or aPerson.birthdate.
6
3551
by: Doug | last post by:
I have data that looks something like this when returned from a stored procedure (3 columns, X rows): Key1 Name1 Value1 Key1 Name2 Value2 Key1 Name3 Value3 Key1 Name4 Value4 Key2 Name1 Value1 Key2 Name2 Value2 Key3 Name1 Value1
4
2209
by: Arjen | last post by:
Hi, I need to add this inside an array: 1 3 2 4 3 2 4 5 5 1 I think of using this:
12
372
by: simon | last post by:
I get the number. Now I must check if this number already was once and if not than store it. What is the best way to do that? Create array at the beginning. When the first number comes, add number to it and when each new number comes, check if it is in the array already and if not add it or something similar? Thank you for your answer,
19
3170
by: Tom Jastrzebski | last post by:
Hello, I was just testing VB.Net on Framework.Net 2.0 performance when I run into the this problem. This trivial code attached below executed hundreds, if not thousand times faster in VB 6.0 than in .Net environment, under VS 2005 Beta 2. Does anyone have any idea whether this will be addressed in the final release? Thanks, Tomasz
16
10562
by: John Kelsey | last post by:
Back in the "old" days with C, I used to do something like... struct { char Description; float price; } Items = { {"Apple", 1.99}, {"Banana", 2.04}
3
2252
by: Mukesh | last post by:
Hi I am creating a web application in which I am using datagrid. In this application I am creating a shopping cart sort of application, I have primery keys of selected items in a array i want to take full details of the them in a single datareader. How can i do this passing a single hashtable or array in database and retriving the desired data in a single datatable. plz give me any idea or link Thx Mukesh Agarwal
0
10170
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11592
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11359
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10699
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7435
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4954
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4545
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3553
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.