Link to home
Start Free TrialLog in
Avatar of Nerdy_Girl88
Nerdy_Girl88

asked on

can i bind a text field to a dataview table field VB.net

Hi

I have a form that has three text fields, a combobox and datagrid.   I have a one to many relationship with the form and the datagrid.  the combobox is used to let the user choice which record they want to look at.  I havetwo data Adapters, one for each table.  A dataset and a relationship, and two dataviews. I am using the rowFilter to populate two dataviews.

Dataview1 is bound to the datagrid. this is good

Can i bound Datagrid2 to the text Fields on my form?

Here is the code that i am trying to use, i get ti error,
Class "System.data.datatable" ca not be indexed because it has no default property

Try
            Dim strLocation As String
           
 'bind the data in the database to the textfields in the form, this doesn't work
            Me.txtAccessID.DataBindings.Add("text", DvTextFields.Table("Accessorie"), "Accessorie_ID")
            Me.rtxtDesc.DataBindings.Add("text", DvTextFields.Table("Accessorie"), "Access_Desc")
            Me.cboAccessType.DataBindings.Add("text", DvTextFields.Table("Accessorie"), "Access_Type")
            Me.txtPrice.DataBindings.Add("text", DvTextFields.Table("Accessorie"), "R_List_Price")
           
 'bind the datagrid to te view, this works
            Me.dgrModels.DataSource = DvDatagrid

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

thanks
ASKER CERTIFIED SOLUTION
Avatar of keijerjh
keijerjh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nerdy_Girl88
Nerdy_Girl88

ASKER

Thanks for your help, your right thatswhat i want to do,

here is the table design

Accessory table  (Master,parent)   one to many relationship  Accessory_Model table(child)    

Accessory table
Accessory_ID(PK)
Accssory_Name
Description

Accessory_Model
Accessory_ID(FK)
Mode_ID(FK)

these is also another parent table, i don't need right now
table Model

I also have,
Data Adapters  DaAccessory  and DaAccess_Model
Data Set   DsAccess_Model  with a relationship Access_Model
Data View DvAccessModelDgr DvAccessModelTxT

I am using dataviews, to so i filter the dataset with the selected value from the combobox, and then bind the dataviews to the data fields and data grid,  I was going to use the dataset but, would have have to use a parameterised query to populate the dataset,  Would this be a better way?  Im confused how the parameterised query will work with two data adapters.  Do I need to use the parameter on both adapters or just one?

Currently on the form The datagrid works but the textfields don't work,  How will the dataview effect my save/add/edit button?  I see alot of people have problems with dataviews.  is this your experience?  Do you use dataViews?

is this what your looking for
thanks.

Turns out I will need that other table

Model
ModelID(PK)
Model_Name
Model_Desc

The data grid will hold the Access_Model table details,  I want to the Access_Model.ModelID to be a dropdown box in my datagrid.  I want the Access_Model.AccessoryID to be populated with the parent PK(Accesory.AccessoryID) and the Access_Model.ModelID to be a list of Models from the Model table.

I know this is asking alot,  so if you know of any links to a tutorial explaining how this could be done that would be great.

my back ground is VBA,  VB.net is so different......it take so long to do anything.
thanks again.