473,385 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Data Grid will not display

Leo
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 DataTable

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

'Sequence
Dim Sequence As DataColumn = New DataColumn
With Sequence
.DataType = System.Type.GetType("System.Int32")
.ColumnName = "Sequence"
.AllowDBNull = False
.ReadOnly = True
.AutoIncrement = True
End With
tblJobItems.Columns.Add(Sequence)

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

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

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

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

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

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

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

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

'LCant
Dim LCant As DataColumn = New DataColumn
With LCant
.DataType = System.Type.GetType("System.String")
.ColumnName = "LCant"
.ReadOnly = False
.AutoIncrement = False
End With
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
Nov 18 '05 #1
3 934
Hi Leo

The reason might be the variable tblJobItems. Though you define as public, it will not persist through posting back. You might consider using ViewState to store it, like
Private tblJobItems As DataTabl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
If Not (Page.IsPostBack) The
'Build datatabl
Els
'Get table from ViewStat
tblJobItems = CType(ViewState("tblJobItems"), DataTable
End I
DataGrid1.DataSource = tblJobItem
DataGrid1.DataBind(
End Su

Private Sub Page_Prerender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRende
'Save table back to ViewStat
ViewState("tblJobItems") = tblJobItem
End Su
Hope this will help

Bin Song, MC

Nov 18 '05 #2
Thanks for Bin's good suggestions.

Hi Leo,

I agree with Bin's solution. In addition to the "ViewState", you can also
use SessionState to maintain DataSource between the page's post back. There
is a example on this in the following link:

#DataGrid.SortCommand Event
http://msdn.microsoft.com/library/en...webuiwebcontro
lsdatagridclasssortcommandtopic.asp?frame=true

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
Hi Leo,

Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If you have anything unclear or if
there're anything else we can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jordan O'Hare | last post by:
Hello Everyone, I am after some help with the following: I have a windows application that contains a list box and two data grids. All three controls are binded to a dataset that contains...
2
by: kk | last post by:
Have 2 problems, any help is appreciated. Tab with Grids -------------- BL - fetching data from DB ( 5 secs - 10 rows) Grid Laod - 20 secs Grid Paint on tab change - 20 secs Problem: The...
0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
5
by: pmud | last post by:
Hi, I need to display columns in a data grid based on 7 different queries. Now I have 32 questions: 1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to...
9
by: VMI | last post by:
We have this huge application that's based on storing tons of data on a dataTable. The only problem we're having is that storing LOTS of data (1 million records) into a datatable will slow down the...
6
by: Hutty | last post by:
I've looked around and have yet to find anything that would answer my question regarding formating a column in a datagrid. My grid looks like this as far as data" AMHQCON|51300.01|-3147 The...
3
by: pmud | last post by:
Hi, I have a web page (asp.net, code:c#). I havean html table with text boxes. Based on the user input , records are displayed in the data grid below it. Now the datagrid has a large no. of...
12
by: Kimberley Wiggins | last post by:
Can someone please help me? I am still learning vb so this is fairly new. I have been chasing this problem for 3 days now and I think that I am ready to give up. Does anyone know how to make...
3
by: Scottie_do | last post by:
I have a 20meg in-memory stack-based array and I'd like to normalise in the client's memory... then add foriegn keys, and display results on a datagrid. I discovered that converting the stack to a...
0
by: Devesh | last post by:
Hi, I want to display some parameters & their value in Same data grid as shown Parameter | Value | Parameter | Value |Parameter | Value So please suggest me the way to Split...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.