Binding to a grid

S

STom

I have a table in my database called Incrementals that has a primary key
IncrementalsID.

I have another table called IncrementalDetails and it has a foreign key of
IncrementalID. The IncrementalDetails table is structured like:

[IncDetailID] [int] NOT NULL ,
[ModelID] [int] NOT NULL,
[IncrementalID] [int] NOT NULL ,
[IncTypeID] [int] NOT NULL ,
[Description] [varchar] (50) NULL ,
[ValuePercent] [decimal](18, 8) NULL ,
[ValueDollar] [decimal] (18,8) NULL,
[DisplaySequence] [int] NOT NULL

I have a datagrid that I want to fill with the incremental details data.
When I get my dataset back from the database, it will look something like:

1 1 1 2 "Item one" 0.5 12.53 1
2 1 1 2 "Item two" 1.2 23.43 2
3 1 1 2 "Item three" 0.3 1.21 3
4 1 2 2 "Item four" 0.5 12.53 1
5 1 2 2 "Item five" 1.2 23.43 2
6 1 2 2 "Item six" 0.3 1.21 3

Notice in the set of records above, that the 3rd column, the IncrementalID
is different. What I need to be able to do is bind the row from the table
that have an IncrementalID =1 to the grid.

Now, when I bind a textbox, I do like this:

Dim lbCurr2 As New Binding("Text",
ds.Tables("CurrentCase"),"AccountsReceivable")
AddHandler lbCurr2.Format, AddressOf DecimalToDollar
Me.lblAR.DataBindings.Add(lbCurr2)

I then have to set the currency manager index like this:

Dim larCurrCaseSort(1) As Object
Dim liCurrCaseRowIndex As Integer
Dim lCaseCurrMgr As CurrencyManager
Dim ldvCurrCase As DataView

ldvCurrCase = New DataView(ds.Tables("CurrentCase"))
ldvCurrCase.Sort = "ModelID,Year"
larCurrCaseSort(0) = ds.Tables("ModelData").Rows(0).Item(0)
larCurrCaseSort(1) = Year(Now)
liCurrCaseRowIndex = ldvCurrCase.Find(larCurrCaseSort)

lCaseCurrMgr =
CType(Me.BindingContext(ds.Tables("CurrentCase")),CurrencyManager)
lCaseCurrMgr.Position = liCurrCaseRowIndex

When I set the currency managers row, that is easy enough to
understand...but how does this work for a grid...I don't want to set it to a
row, I need to set it to a set of rows.

I am thinking that for a grid, what I would need to do is create a dataview
off of my dataset and then do the binding to the dataview and not the
dataset. Is that correct? Or is there another way?

Thanks.

STom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top