| | |||||||
|
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 ... |
| | LinkBack | Thread Tools | Display Modes |
| ||||
| 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 |
| ||||
| 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 |
| ||||
| 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(); |
| ||||
| 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 |
| ||||
| 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 |
| Thread Tools | |
| Display Modes | |
| |
| | ||