473,670 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(dsData set.Customer)
view.Sort = "CustomerID ASC"
DataGrid1.DataS ource = 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.Custo mer.Rows(intRow Pos)("CustomerN ame") = "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.D ataBindings.Add ("Text", dsDataset,
"Customer.Custo merID")
lblCustomerAddr ess.DataBinding s.Add("Text", dsDataset,
"Customer.Custo merAddress")

cmbCustomerName .DataSource = dsDataset
cmbCustomerName .DisplayMember = "Customer.Custo merSurname"
cmbCustomerName .ValueMember = "Customer.Custo merID"

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 CustomerForenam e 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.Cu stomer.Rows.Cou nt

cmbCustomerName .Items.Add(dsTu rbobraze.Custom er.Rows(intRowP os)_
("CustomerSurna me").ToString () & ", " &
dsTurbobraze.Cu stomer.Rows(int RowPos)_
("CustomerForen ame").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 _SelectedIndexC hanged 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 1012

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

Similar topics

0
1068
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 not showing any of the field values. All this was done with the designer. I know that the view is returning a row because I hooked the view up to a datagrid which is displaying it. Do I need to somehow tell the controls to go out and grab...
2
3297
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 the selected lie item at which case I would pop up a separate dialog box to do so, in the debugging code, the dataview.count would return 0. I get a error message because I tried to get values out of a dataview that holds 0 items. Does anyone...
1
1441
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 method: public string getTheField(int index) { ... } - where index would equal 4. How is this written into the property? Does reflection take care of getting the appropriate value?
36
4461
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 dataview with a count = 0. Can someone explain why and how I might work around this problem? Here is the code for my function: Public Shared Function GetViewFromRS(ByVal pRS As ADODB.Recordset) _ As DataView
17
2748
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 allow user to filter the first time, when they tried the second time, the speficied cast error message will prompt one.... I create a mydataset1 first, and the mydataset1 data source was getting from DataGrid.DataSource.
10
1939
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 record using a form or edit various existing records) This way I could minimize transaction on server..
1
1314
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 if I attach the method to the SelectMethod property but the DetailsView does not display it properly. The returned data in the DataRow is correct. Do I need to put the DataRow back in a DataTable first or is there another way? Also, if my class...
7
5615
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 with databinding. The data from the 2 detail tables are displayed in 2 datagridviews. I filter each datagridview with a Dataview object using the dataview.Rowfilter property. This is sort of working except that I am getting an except on one of my...
4
3091
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 applications into Visual Basic.Net. My managers main thought is that Visual Basic 6 is (or has!) stopped being supported by Microsoft.
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8903
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5686
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4393
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2802
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1795
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.