DataGrid using a table not a DataSet

Discussion in 'ASP .Net' started by =?Utf-8?B?TGVv?=, Apr 12, 2004.

  1. 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
    =?Utf-8?B?TGVv?=, Apr 12, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,776
    Chris Taylor
    Oct 31, 2003
  2. David Williams
    Replies:
    2
    Views:
    1,107
    Jacob Yang [MSFT]
    Aug 12, 2003
  3. Nedu N
    Replies:
    2
    Views:
    2,142
  4. donet programmer
    Replies:
    1
    Views:
    502
    donet programmer
    Dec 5, 2006
  5. Nedu N
    Replies:
    2
    Views:
    211
    Jacob Yang [MSFT]
    Oct 31, 2003
Loading...

Share This Page