DataGrid using a table not a DataSet

G

Guest

Thanks for the Help in Advance!

I am a beginner in VB.Net. I am trying to create a form which is displayed in a email for our customers to fill in a Request for quote. I would like them to type data into fields and have it added to the Datagrid

I am constantly getting the error Column 'OALen' does not belong to table .

Any Ideas


Public tblJobItems As New DataTabl

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
If Not (Page.IsPostBack) The

'Sequenc
Dim Sequence As DataColumn = New DataColum
With Sequenc
.DataType = System.Type.GetType("System.Int32"
.ColumnName = "Sequence
.AllowDBNull = Fals
.ReadOnly = Tru
.AutoIncrement = Tru
End Wit
tblJobItems.Columns.Add(Sequence

'Quantit
Dim Quantity As DataColumn = New DataColum
With Quantit
.DataType = System.Type.GetType("System.Int32"
.ColumnName = "Quantity
.ReadOnly = Fals
.AutoIncrement = Fals
End Wit
tblJobItems.Columns.Add(Quantity

'FamilyTyp
Dim FamilyType As DataColumn = New DataColum
With FamilyTyp
.DataType = System.Type.GetType("System.String"
.ColumnName = "FamilyType
.ReadOnly = Fals
.AutoIncrement = Fals
.Caption = "Truss Type
End Wit
tblJobItems.Columns.Add(FamilyType

' Over All Lengt
Dim OAL As DataColumn = New DataColum
With OA
.DataType = System.Type.GetType("System.String"
.ColumnName = "OALen
.ReadOnly = Fals
.AutoIncrement = Fals
.Caption = "Over all Length
End Wit
tblJobItems.Columns.Add(OAL

'Hee
Dim Heel As DataColumn = New DataColum
With Hee
.DataType = System.Type.GetType("System.String"
.ColumnName = "Heel
.ReadOnly = Fals
.AutoIncrement = Fals
End Wit
tblJobItems.Columns.Add(Heel

'Item Descriptio
Dim Description As DataColumn = New DataColum
With Descriptio
.DataType = System.Type.GetType("System.String"
.ColumnName = "Description
.ReadOnly = Fals
.AutoIncrement = Fals
End Wit
tblJobItems.Columns.Add(Description

'Pitc
Dim Pitch As DataColumn = New DataColum
With Pitc
.DataType = System.Type.GetType("System.String"
.ColumnName = "Pitch
.ReadOnly = Fals
.AutoIncrement = Fals
End Wit
tblJobItems.Columns.Add(Pitch

'LOverHang
Dim LOverHang As DataColumn = New DataColum
With LOverHan
.DataType = System.Type.GetType("System.String"
.ColumnName = "LOH
.ReadOnly = Fals
.AutoIncrement = Fals
End Wit
tblJobItems.Columns.Add(LOverHang

'ROverHan
Dim ROverHang As DataColumn = New DataColum
With ROverHan
.DataType = System.Type.GetType("System.String"
.ColumnName = "ROH
.ReadOnly = Fals
.AutoIncrement = Fals
End Wit
tblJobItems.Columns.Add(ROverHang

'LCan
Dim LCant As DataColumn = New DataColum
With LCan
.DataType = System.Type.GetType("System.String"
.ColumnName = "LCant
.ReadOnly = Fals
.AutoIncrement = Fals
End Wit
tblJobItems.Columns.Add(LCant

'RCant
Dim RCant As DataColumn = New DataColumn
With RCant
.DataType = System.Type.GetType("System.String")
.ColumnName = "RCant"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(RCant)

'BearingSize
Dim BearingSize As DataColumn = New DataColumn
With BearingSize
.DataType = System.Type.GetType("System.String")
.ColumnName = "BearingSize"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(BearingSize)

'SpecialNotes
Dim SpecialNotes As DataColumn = New DataColumn
With SpecialNotes
.DataType = System.Type.GetType("System.String")
.ColumnName = "SpecialNotes"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(SpecialNotes)
' Create an array for DataColumn objects.
Dim keys(0) As DataColumn
keys(0) = Sequence

Dim PrimaryKeyColumns(0) As DataColumn
PrimaryKeyColumns(0) = tblJobItems.Columns("Sequence")
tblJobItems.PrimaryKey = PrimaryKeyColumns
End If
DataGrid1.DataSource = tblJobItems
DataGrid1.DataBind()

End Sub

Private Sub btnADDTrussItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnADDTrussItem.Click

'Insert new row into the dataset table
Dim dr As DataRow = tblJobItems.NewRow()
dr("OALen") = tbOAL.Text
dr("Heel") = ddlHeel.SelectedValue
tblJobItems.Rows.Add(dr)
'Refresh the grid
DataGrid1.EditItemIndex = -1
End Sub
 

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

Similar Threads

Data Grid will not display 3
Solution Required 2
Add DataColumn to DataSet 1
Dynamic DataSet In A DataGrid 1
Master/Detail 0
Master/Detail 0
Add Rows to a Table 1
trying to bind a typed dataset to a datagrid 1

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top