Easy way to replace Data with ComboBox? Or populate ComboBox from Data - data-binding

I took over a very old project written in VB6, it's a mess and I don't really know VB so it would be great if someone could help me.
I have a Data control which gets records from an Access database which I would like to replace with some kind of drop down list - I thought about ComboBox. Unfortunately I cannot get records from the database in the same way as with Data, so I thought about populating ComboBox based on what's in the Data control. How can I achieve it? Or is there a better way to do it?
My last resort is to create all database methods manually in order to replicate Data's behaviour for ComboBox but I think it's too much effort for such a small change.
Thanks in advance!

The Data control does more than just let them browse through the records, it manages the database, current record, data binding, etc.
The easiest way to do what you want is to hide/move the data control and use its .Recordset.Find*() methods.
Note that DAO is archaic and has been supersceded at least once for VB6 (with ADO)

Related

ASP.Net Datagridview paging without using SQL Server

I'm working on one project where data is coming from the WCF web services and in the List format.
Firstly, Is it possible to assign that list directly to the data grid view? If not then I'm converting that list into Dataset and binding to the Grid but the problem is, Collection List contains thousand of records and converting into Dataset decrease the performance.
Also, This is a direct bing with List or the Dataset to Gridview so is it possible to achieve the paging including First, Previous, Next, Last and Page sets?
Your help would be appreciated.
Thank you in advance for the help!
Dhaval
I dont think you can 'directly' do it but somehow , theres a way. Here is a question of the same matter.
Gridview using a generic list as DataSource and Auto-generating columns

Ideas for Quick Hierarchical Listing - .NET

I have a table in SQL Server listing corporate departments and their sections and subsections (3 levels). I would like to create some web-based listing of this, but similar to a TreeList.
I was thinking to set up nested Ajax Accordions, but it was taking me way too long to put together. I would even settle for a GridView with non-repeating column values.
Is there a way I can implement my idea without it taking me more than an hour or so for a newbie to complete? Any controls in ASP.NET or Ajax I can bind to would be great.
Thanks to Ozzy, I was able to solve this simple issue using a TreeList. Since my issue is simlper than the one in the tutorial he supplied, all I did was create DataTable for each level, and for each row I added the TreeNode (which was simply the string value of that entry). Thanks!!

What to use for a datagrid with a lot of data?

Found this interesting interview question:
You need to display the sales data for your division for the past 5 years in a DataGrid on a Web Form. Performance is very important. What would be the best strategy to use in retrieving the data?
a)Use a DataReader object to retrieve
the data for the DataGrid.
b)Use a DataSet object to retrieve the
data for the DataGrid.
c)Use a simple select statement as the
data source for the DataGrid.
d)Use a cached XML file as the data
source and retrieve the data with a
DataSet.
My answer is c) but I am not too sure
Can anyone point me to the right answer and explain it to me please
Thanks
I'd use paging.
You can also accomplish this using stored procedures.
Basically any time a test mentions performance and DataReader and DataSet, the rule of thumb is DataReader == fast and DataSet == slow.
I'd probably say choice A of the answers provided, but paging is definitely the more correct answer. DataSets are slow and load the whole table while DataReader is really fast, just iterating over the records.
Using a select statement as the datasource is just bad practice and never recommended.
If performance is very important then don't use a datagrid, use a repeater or an ordinary loop.
I would assume a cached XML file (memomry) is faster than retrieving data from a database BUT could also use a considerable amount of memory, so not the right answer I think.
A select statement and a DataReader is very much alike, but you have some more out-of-the-box features with a DataReader, so that would be my answer.

How to Bind Data to an ASP.NET ListBox Control?

How can I bind data from a database to a ListBox control in ASP.NET?
Basically, you:
make a connection to the database and select the data (there are a whole bunch of variables that will dictate the best way to do this)
ensure your data is in an IEnumerable container, such as List< object>
assign the IEnumerable list to the Items/ItemSource property of the control
call DataBind() on the control
Of course this won't work for every control, a textbox will have to be done differently. This probably didn't help you much at all, when you have more exact questions then people can give you more exact answers. If you ask vague questions with a lot of different ways of achieving the desired outcome then nobody can give you exact step by step instructions.
See Web Forms Data on the http://asp.net site.

asp.net - Possible to have formview edit data across multiple tables?

I am attempting to construct a formview that will edit two related objects at once.
In basic terms, I have a Linq To SQL object of teacher which has exactly one school. The formview has no problem displaying the data, but when in edit mode will only save the changes done to the parent object. Changes to the school data are seemingly ignored
Is there any way to achieve the kind of thing I want here?
Thanks,
This is probably similar to what I'm doing, although I'm not using Linq. I'm using a vanilla ObjectDataSource and displaying data in a drop down list via a different data source. Add a new Event for the FormView that is called during the "ItemUpdating" event. Embed code to directly save your changes in that event. Then as the FormView is saved, everything else is saved.
If you want it to be saved after the FormView, use the ItemUpdated event instead. It's a bit of a manual process, but it does get around the problem.

Resources