473,770 Members | 5,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Initiallizing problem in Web application

2 New Member
hello guys, i hope any one will help in this

i am designing a web application, the page i am workin on its the default.aspx
it contains dropdownboxes

the first 4 to choose the type and the second for to choose the value of the type

when you choose a type a dropdownlist will be filled of values that related of that type.
and when you choose a second type , it will also will filled the value that related of the second type, and it will use the filter of the first dropdownlists to reduce the data. and so on fot the forth type dropdownlist.

i have 3 classes, controller, database, and TypeValue.

when u choose a type, it will send the controller and the controller will create an object of type TypeValue and insert it in array of the same type that has been initialized in the controller.
then it will call the database class to retrieve the values of that type, and it will return the values as an OLEDatareader to the controller then to the Default.aspx to the dropbox of the value.

then when u choose from that list a value, it will call the controller, then the controller will just modify the value parameter in the array in the controller class.

now when the user will select the second value, it will go to the controller and create another object and it will insert it in the second index of the array, the problem that i am facing, is the first index turns to null.

i think this is because the web application will initialize the variables everytime it will call a method in the class. so i want it just to be intiallized once when i call it for the first time. i tried to use the HTTPApllication , method Application_sta rt, this method will be called just one time, which is when the application started, but my problem with this method, is that i cant use the array out side it, if i initiallized the array inside it.

here are the code.


Dropbox to choose the first type
Expand|Select|Wrap|Line Numbers
  1. protected void DropDownList6_SelectedIndexChanged(object sender, EventArgs e) 
  2.                 DropDownList1.Enabled = true;
  3.                 CheckBox5.Enabled = true;
  4.                 oldr = fc.SelectFilterType(DropDownList6.SelectedItem.Value, 0, null );
  5.                 DropDownList1.DataSource = oldr[0];
  6.                 DropDownList1.DataValueField = DropDownList6.SelectedItem.Value;
  7.                 DropDownList1.DataBind();
  8.  
  9. dropbox to choose the second type
  10.     protected void DropDownList7_SelectedIndexChanged(object sender, EventArgs e) 
  11.                 DropDownList2.Enabled = true;
  12.                 CheckBox6.Enabled = true;
  13. null);
  14.                 oldr = fc.SelectFilterType(DropDownList7.SelectedItem.Value, 1, null);
  15.                 DropDownList2.DataSource = oldr[1];
  16.                 DropDownList2.DataValueField = DropDownList7.SelectedItem.Value;
  17.                 DropDownList2.DataBind();
  18.  
  19. dropbox to choose the first value
  20.     protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)//first ddl 
  21.     {
  22.         if (DropDownList2.Enabled == true || CheckBox6.Checked == true)
  23.         {
  24.             oldr = fc.SelectFilterValue(DropDownList1.SelectedValue, 0);
  25.             DropDownList2.DataSource = oldr[1];
  26.         }
  27.     }
the controller class
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data;
  6. using System.Data.OleDb;
  7.  
  8. /// <summary>
  9. /// Summary description for Controller
  10. /// </summary>
  11. public class FilterController 
  12. {
  13.     public string filterType;
  14.     public int listIndex;
  15.     public string filterValue;
  16.  
  17.     public FilterTypeValue[] filterTypeList = new FilterTypeValue[4];
  18.     public DatabaseClass dbClass;
  19.  
  20.  
  21.  
  22.     public FilterController()
  23.     {
  24.  
  25.     }
  26.     public FilterController(string filterType, int listIndex, string filterValue)
  27.     {
  28.         //
  29.         // TODO: Add constructor logic here
  30.         //
  31.         this.filterType = filterType;
  32.         this.filterValue = filterValue;
  33.         this.listIndex = listIndex;
  34.         //filterTypeList[listIndex] = new FilterTypeValue(filterType, filterValue);
  35.  
  36.     }
  37.  
  38.     public OleDbDataReader[] SelectFilterType(string filterType, int listIndex, string filterValue)
  39.     {
  40.         filterTypeList[listIndex] = new FilterTypeValue(filterType, filterValue);
  41.         dbClass = new DatabaseClass(filterTypeList,listIndex);
  42.         return dbClass.FilterData();
  43.     }
  44.     public OleDbDataReader[] SelectFilterValue(string filterValue, int listIndex)
  45.     {
  46.         filterTypeList[listIndex].Value = filterValue;
  47.         if(this.listIndex < 3)
  48.             dbClass = new DatabaseClass((FilterTypeValue[])filterTypeList.Clone(), listIndex + 1);
  49.         return dbClass.FilterData();
  50.     }
TypeValueClass
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5.  
  6. /// <summary>
  7. /// Summary description for Class1
  8. /// </summary>
  9. public class FilterTypeValue
  10. {
  11.     public string filterType;
  12.     public string filterValue;
  13.     public object Clone()
  14.     {
  15.         FilterTypeValue p = new FilterTypeValue(filterType,filterValue);
  16.         return p;
  17.     }
  18.  
  19.  
  20.     public FilterTypeValue(string filterType, string filterValue)
  21.     {
  22.         //
  23.         // TODO: Add constructor logic here
  24.         //
  25.         this.filterType = filterType;
  26.         this.filterValue = filterValue;
  27.     }
  28.     public string FType
  29.     {
  30.         get
  31.         {
  32.             return filterType;
  33.         }
  34.         set
  35.         {
  36.             filterType = value;
  37.         }
  38.     }
  39.     public string Value
  40.     {
  41.         get
  42.         {
  43.             return filterValue;
  44.         }
  45.         set
  46.         {
  47.             filterValue = value;
  48.         }
  49.     }
  50. }
the database class
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data.OleDb;
  6.  
  7.  
  8.  
  9. /// <summary>
  10. /// Summary description for DatabaseClass
  11. /// </summary>
  12. public class DatabaseClass :HttpApplication
  13. {
  14.     public int connectionNumber;
  15.  
  16.     public OleDbConnection oLDConnection;
  17.     public String connectionString1 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\Users\\tabbaanm\\Desktop\\Facility Ins WebAppl\\App_Data\\KPGDatabase.accdb;Persist Security Info=True";
  18.     public OleDbCommand cmd;
  19.     public OleDbDataReader [] oldr = new OleDbDataReader[4];
  20.  
  21.     public string[] t = new string[5];
  22.     public string[] f = new string[4];
  23.  
  24.     FilterTypeValue[] filterTypeList = new FilterTypeValue[4];
  25.  
  26.  
  27.     public DatabaseClass(FilterTypeValue[] filterTypeList, int connectionNumber)
  28.     {
  29.         //
  30.         // TODO: Add constructor logic here
  31.         //
  32.  
  33.         this.connectionNumber = connectionNumber;
  34.         this.filterTypeList = filterTypeList;
  35.     }
  36.     public OleDbDataReader[] FilterData()
  37.     {
  38.         switch (connectionNumber)
  39.         {
  40.             case 0: Connection1();
  41.                 break;
  42.             case 1: Connection2();
  43.                 break;
  44.             case 2: Connection3();
  45.                 break;
  46.             case 3: Connection4();
  47.                 break;
  48.             default: Connection1();
  49.                 break;
  50.         }
  51.         return oldr;
  52.     }
  53.  
Sep 15 '09 #1
1 1583
aboalnodom
2 New Member
loool i have solved it,, i made the array as static to be initiazlied once, and now its working

if i have any problems in coding, i think i will be post here :D
Sep 15 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3291
by: J. Baute | last post by:
I'm caching data in the Application object to speed up certain pages on a website The main reason is that the retrieval of this data takes quite a while (a few seconds) and fetching the same data from the "cache" hardly takes any time A basic pattern used to get the data from disk, or from cache is this data = getDataFromCache("mydata" if data = "" the data = getDataFromDisk( storeDataInCache(data, "mydata" end i
3
3150
by: Amit Dedhia | last post by:
Hi I am developing a Dot net application (involving image processing) on a uni processor. It works well on my machine. I then take all my code on a multi processor, build and run the application there. There is performance degradation. The usual performance of the application on MP machine is better than that of uni processor machine. But the performance of MP degrades when it comes to the multi-threaded part of the application. I am...
6
20087
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are quite a few words in this post but the questions are actually quite similar and should be fairly quick to answer ... (1) What is Happening with the Threads
20
2720
by: Peter Oliphant | last post by:
How does one launch multiple forms in an application? Using Photoshop as an example, this application seems to be composed of many 'disjoint' forms. Yet, they all seem somewhat 'active' in contrast to one of them always being 'modal' (e.g., if you are moving over a picture the 'Info' form will update the (x,y) screen location in realtime even if not the selected form. Also note that this example implies the various forms can communicate...
6
25068
by: Josef Brunner | last post by:
Hi, I published my application (VS 2005) and am now trying to install it when I get this error message. It worked before...even on a different machine. Here is the detailed description: PLATFORM VERSION INFO Windows : 5.1.2600.131072 (Win32NT) Common Language Runtime : 2.0.50727.42
9
2988
by: jeff | last post by:
Hi All. I realize that when my Deployed winforms application starts, Windows needs to load the .net 2 framework before control is given to my application.... Is there anyway to either ... - preload the .net 2 framework (windows startup or whatever) - splash a screen ... application loading ... please wait ... type of
3
2693
by: asadikhan | last post by:
Hi, I have written a windows application with a GUI (let's call it MENU). I own the code for this application and have access to it. We have another application that is a third-part windows application with a GUI interface as well (let's call it BASE). I don't have access to the code of this application. This application has hooks through which other applications can be called. I have defined a hook in this application which bring up...
2
4544
by: Michael Kalika | last post by:
Hi, We have developed a VSTO 2005 Excel application and we would like to leverage ClickOnce deployment mechanism for distribution of this application. How can we do that? I was digging in MSDN for VSTO & ClickOnce documentation and did not find anything. I've noticed that there is an option to publish the project, but when I do that and then run the application from Web it throws us security errors like:
0
5252
by: Tifer | last post by:
Hello, I am building my first .Net Application. The first couple of Publish and Installs I did went fine. But after a couple of builds, I get a modal dialogue box error every time upon trying to install using the setup.exe. Title is "Cannot Start Application" and it says: ==================== Cannot download the application. The application is missing required files. Contact application vendor for assistance.
0
9591
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
10225
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...
0
9867
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
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
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
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2816
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.