Yorkshire Divers

Deep Blue Technical
Go Back   YD Scuba Diving Forums > Non-Diving Related Forums > Technology
User Name
Password

Welcome to the YD Scuba forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Technology: Discuss ASP/C#.NET Question: Populate Webform Controls Dynamically in the Non-Diving Related Forums forums: As relatively new to C#/ASP.Net, I'm struggling with the concept of this task, so as most of the forums are ...

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-09-06, 10:49 AM
MartinS's Avatar
Senior Member
 

Join Date: Jul 2002
Location: Redhill, Surrey
Posts: 1,552
MartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the sea
ASP/C#.NET Question: Populate Webform Controls Dynamically

As relatively new to C#/ASP.Net, I'm struggling with the concept of this task, so as most of the forums are US based, want to get moving with this before lunchtime, so I'm passing it over to the YD massive to see if there is anyone who can get the ball rolling for me.
I have a webform which contains several listbox controls (amongst others), and need to be able to store the relevant info from each one, i.e. a list of the listbox's text items, their corresponding values and the text item selected, so that at any time, I can re-populate the listbox controls with the relevant data. Currently, each time, the page is accessed, it has to read from a SQL database to populate the controls, but to try and speed up the process I am attempting to store all of the possible info on the page so that it does not need to access the SQL database each time. I'm guessing it will be best to store the items listed in session based on the control name (I could be wrong!), so that they can be recalled and applied to the correct control, but am not sure how best to retain the data, and then how to return all the info back to the control. My initial plan was to use a utilites class to store all the common code, but now think it may need to be done within the code module of the webform.
Can anyone get me started on the best way to do this?
Regards, and thanks in advance...
Martin
__________________
Never test the depth of the water with both feet!
69 Divers SAC
Yorkshire Divers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-09-06, 11:04 AM
RonProwse's Avatar
why does it always do that......
 

Join Date: Feb 2006
Location: Chatham
Posts: 537
RonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold water
If the data you need to load in to the controls is only relevant to the person accessing the page then store the data in the Session otherwise if the data is the same across the web application then store it at the application level this way the you only need to load data once where as you would load data each time the user connect to the application.

Ron
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-09-06, 11:39 AM
MartinS's Avatar
Senior Member
 

Join Date: Jul 2002
Location: Redhill, Surrey
Posts: 1,552
MartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the sea
Hi Ron
I understand what you are saying, but my question was really aimed at how to store all the info for a control in one place so it can be recalled at any time. The info is relevant to the user, as more than one person can be using the system at any one time and each user sees their own specific data/views.
Is writing the info to an XML file worth considering? It looks like reading from XML into a listbox control is relatively straight-forward, but can an XML file be created, written to and then saved easily? I really wanted to design a method that would populate any listbox control to save me replicating code for each relevant listbox. I guess the control's name, it's values and text items could be parameters, but what data type is a listbox's list?
Any other ideas/code examples gratefully received
Regards
Martin
__________________
Never test the depth of the water with both feet!
69 Divers SAC
Yorkshire Divers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-09-06, 02:11 PM
RonProwse's Avatar
why does it always do that......
 

Join Date: Feb 2006
Location: Chatham
Posts: 537
RonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold water
if the datan returned as a datatable (.net object) then just use
Session.add("controldata", dtreturneddata);
to get at the data
listcontrol.datasource = (DataTable)Session["controldata"];
listcontrol.databind();
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-09-06, 02:57 PM
MartinS's Avatar
Senior Member
 

Join Date: Jul 2002
Location: Redhill, Surrey
Posts: 1,552
MartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the sea
Ron
Sorry, looks OK except I'm not sure that I have a data table!
How do I convert the Items list of the ListBox to a datatable (so it contains both the Name and Value elements of each list item)?
Thanks
Martin
__________________
Never test the depth of the water with both feet!
69 Divers SAC
Yorkshire Divers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-09-06, 04:49 PM
RonProwse's Avatar
why does it always do that......
 

Join Date: Feb 2006
Location: Chatham
Posts: 537
RonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold waterRonProwse swims in cold water
if your using Visual Studio do you have the dynamic help window open (if the msdn installed) then by typing :-

Listbox l = new listbox(); and clicking on the word listbox will bring up the help window for it that should guide you.

Ron
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Sponsored Links

Yorkshire Divers - RSS Feed
All times are GMT +1. The time now is 11:28 AM.
Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Trademark and all rights reserved : © YD.com Ltd (2006)
YD.com Ltd (Registered in England - 05886696)
Other sites : Golf Clubs | New Premiership Football Kits | MP3 Portable Players | MP3 Players For Sale | Replica Football Kits | Cheap Football Boots

Forums Directory