Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 468
  • Last Modified:

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
0
Nerdy_Girl88
Asked:
Nerdy_Girl88
  • 2
1 Solution
 
keijerjhCommented:
Hi,

I believe you want to create a Master-Detail form?
If so you should create a dataset wich contains the two tables 'Models' and 'Accessorie'.
Create a relation, for example 'fk_Accessorie2Models'.
Bind you masterdata (textboxes) to the DataSet and use the Datamember 'Accessorie' and bind your detail data to
the dataset with the datamember "Accessorie.fk_Accessorie2Models".
Please send the table-design.
Greetings,
Yelle
0
 
Nerdy_Girl88Author Commented:
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.

0
 
Nerdy_Girl88Author Commented:
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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now