|
-
Apr 8th, 2005, 01:11 PM
#1
Thread Starter
Frenzied Member
data grid
Hey,
How would I add rows and columsn to the data grid control without binding it. I do not want to bind any data to it and populate it manually?
Thanks,
Don't anthropomorphize computers -- they hate it
-
Apr 8th, 2005, 01:59 PM
#2
Lively Member
Re: data grid
I have code for this. I will be back in a few
-
Apr 8th, 2005, 02:02 PM
#3
Lively Member
Re: data grid
Here, I copied it from one of my earlier projects.
Let me know if you have problems with it.
'Here is how you create an empty datagrid, to show
'empty values when your page loads...
VB Code:
Dim mydatacolumn As New DataColumn
Dim mydatatable As New DataTable
Dim columnsneeded As Integer
columnsneeded = 6
While (columnsneeded > 0)
mydatatable.Columns.Add(mydatacolumn)
mydatacolumn = New DataColumn
columnsneeded = columnsneeded - 1
End While
mydatatable.Columns(0).ColumnName = "Mixed"
mydatatable.Columns(1).ColumnName = "Box Number"
mydatatable.Columns(2).ColumnName = "Description"
mydatatable.Columns(3).ColumnName = "Create Date"
mydatatable.Columns(4).ColumnName = "Location"
mydatatable.Columns(5).ColumnName = "Active"
Dim mydatarow As DataRow
Dim columns As Integer
columns = 0
Dim values(5) As Object
While (columns < 6)
values(columns) = "0"
columns = columns + 1
End While
mydatatable.Rows.Add(values)
mydatatable.Rows.Add(values)
mydatatable.Rows.Add(values)
mydatatable.Rows.Add(values)
mydatatable.Rows.Add(values)
mydatatable.Rows.Add(values)
mydatatable.Rows.Add(values)
mydatatable.Rows.Add(values)
Dim mydataset As New DataSet
mydataset.Tables.Add(mydatatable)
mydatagrid_OT.DataSource = mydataset
mydatagrid_OT.DataBind()
-
Apr 8th, 2005, 02:05 PM
#4
Thread Starter
Frenzied Member
Don't anthropomorphize computers -- they hate it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|