Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bind a dataset to a combobox and inside a datagrid! 1

Status
Not open for further replies.

Takis

Instructor
Oct 12, 2001
57
0
0
GR
I tried to constuct a datagrid with some simple cells and some combobox cells.

This what i m trying to do:

I fill all the simple cells from a dataset called "dataset91" but i try to bound to the combobox cell of the datagrid the data from another dataset called "dataset101" and specific the values of a field in "dataset101" called "service code" from the table called "service codes".
"detailcont" is the name of the datagrid.
"contractsn" is the name of the table in the database from witch all the simple cells of the datagrid will be bounded.

The field "service" in dataset91 is a string such as the field "Service code" in dataset101.


Here is the code:

dim tbdet As New DataGridTableStyle
Dim cm As CurrencyManager = BindingContext(detailcont.DataSource, detailcont.DataMember)
Dim connectionstring, selsql As String
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\mobile\comm.mdb;Mode=Share Deny None;Jet OLEDB:Database Password='hellas'"
Dim dv As DataView = CType(cm.List, DataView)

Me.DataSet91.Tables("contractsn").Clear()
DataSet91.Clear()
detailcont.DataSource = DataSet91.Tables("contractsn")
' OleDbDataAdapter5.Fill(DataSet91)
Dim selread As OleDbDataReader
tbdet.MappingName = "contractsn"

'''
...........................

Dim ComboTextCol As New DataGridComboBoxColumn
ComboTextCol.ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList
With ComboTextCol
.MappingName = "service"
.HeaderText = "Service code"

.Width = 100


.ColumnComboBox.DataSource = DataSet101.Tables("Service codes").DefaultView
.ColumnComboBox.DisplayMember = "Service Code"



tbdet.PreferredRowHeight = .ColumnComboBox.Height

End With

tbdet.GridColumnStyles.Add(ComboTextCol)

tbdet.HeaderForeColor = Color.DarkGreen
detailcont.TableStyles.Add(tbdet)

Allthough the combo does not fill?
What may be the problem?
Thank you
 
Dont you have to loop the dataset and fill the combobox? whats the style of the combobox?
 
The style is dropdownlist.
How to loop the dataset?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top