VB.Net - Databinding help

~J~

~J~

Soldato
Joined
20 Oct 2003
Posts
7,558
Location
London
Currently got a combo box, databound to a dataset.

In my code however, I want to be able to have something like...

Me.ComboBox.UID=5

Where UID is a public event that looks through the dataset the control is bound to until it comes to a number 5 in a uid column, and then just updates the combo box with what is in row 5.

Any ideas?
 
can't you just do it via an sql statement ? will make the page more efficient as by the sounds of it your databinding and retrieving the entire contents of the table your binding to then just selecting 1 or more items out of it.

Would be a lot more efficient if you just retrieved exactly what you need from the database.
 
Well yes you're right, if it was a large table, but it's simply a collection of VAT types from a pre-populated dataset which holds about 10 records, so hardly any strain at all really.

One thing that would make it a lot easier for me to use as well (it's a custom control), is to add a databinding to the control itself.

By this I mean if you create a custom control, and place it on your form and look at the databinding properties, it only shows "Advanced" and "Tag". Is there any way to add a new parameter to that range?
 
been a few months since I realy got into some .Net coding but you should be able to access some more properties from the code behind file. If your using visual studio just type in the name/id of the control and dot ( . ) and it should give you the list off all the properties associated with that object. Just a case of finding the one that does what you want really..... if it exists :)


suppose when thinking about it you could do the databinding in the code behind file as opposed to on the control itself. So in the code behind file write the code that retrieves the the contents of the table in the form of a datareader as opposed to a dataset then just loop through the datareader take out what you don't want then databind to the control and pop out just want you need. But at the end of the day your going to be writing maby 5-8 lines of code when just altering your sql statement would work just as well.
 
Last edited:
Back
Top Bottom