473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A few basic questions on DataView and DataBinding (Mainly syntax)

1. If I create a sorted DataView object from a DataSet table, how do I
reference the sorted elements? (Say I want to output the CustomerName
for the first row in the sorted DataView to a label or textbox)

Dim view As DataView = New DataView(dsDataset.Customer)
view.Sort = "CustomerID ASC"
DataGrid1.DataSource = view

2. If after displaying the CustomerName above for the first row in the
sorted DataView, how do I then change it's value. Normally with a
DataSet I'd use:

dsDataset.Customer.Rows(intRowPos)("CustomerName") = "John Smith"

But how would it be done using the DataView. I know a DataView is read
only so obviously I'll have to pass a paramater to the Dataset code
above so it knows, that "this DataView row matches this DataSet table
row".

3.
lblCustomerID.DataBindings.Add("Text", dsDataset,
"Customer.CustomerID")
lblCustomerAddress.DataBindings.Add("Text", dsDataset,
"Customer.CustomerAddress")

cmbCustomerName.DataSource = dsDataset
cmbCustomerName.DisplayMember = "Customer.CustomerSurname"
cmbCustomerName.ValueMember = "Customer.CustomerID"

The above code populates and binds a ComboBox so that when a Surname is
selected it simply outputs the related CustomerID and CustomerAddress
to labels. How do I make it so that both CustomerSurname and the
related CustomerForename both appear in the ComboBox?
4. What's the alternative to Q3 if I don't wanna use Binding. This is
what i have so far:

Private Sub FillComboBox()
Dim intCustomerRow As Integer = 0
cmbCustomerName.Items.Clear()

Do Until intCustomerRow = dsTurbobraze.Customer.Rows.Count

cmbCustomerName.Items.Add(dsTurbobraze.Customer.Ro ws(intRowPos)_
("CustomerSurname").ToString() & ", " &
dsTurbobraze.Customer.Rows(intRowPos)_
("CustomerForename").ToString())
intCustomerRow = intCustomerRow + 1
intRowPos = intRowPos + 1
Loop
End Sub

But all this does is fill the ComboBox with the Forenames and Surnames.
I've tried loads of code in cmbCustomerName_SelectedIndexChanged but
none works.
I know these are basic Q's, but they also tend to be difficult to find
since everyone assumes everyone else knows it.

--

Aziz

Mar 30 '06 #1
0 998

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dan.benge | last post by:
I have a form with some text boxes, checkboxes and DateTimePicker controls. I've bound these controls to fields in a dataview. The problem is when I set the filter on the dataview the controls are...
2
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit...
1
by: ASP Yaboh | last post by:
1. If I use an ArrayList as my data source, how do I construct the accessor methods? That is, forget about properties for a moment, if I wanted the 5th item in the ArrayList, I would write the...
36
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
10
by: Marc R. | last post by:
Hi all, I edit records using a form that have multiple control bind on Dataview, But I don't want to update right always to database, I would like to delay until all Changes (add all new...
1
by: J055 | last post by:
Hi I have a Business class called User which returns a DataRow for individual user accounts using accountID as a parameter (i.e. User.Retrieve(accountID)). The ObjectDataSource doesn't complain...
7
by: Rich | last post by:
Hello, I am pulling master data from one master table and detail data from two detail tables. The rows from the master data are displayed in textboxes on my form which are bound to the data...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.