Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataGrid Issue

Thread Tools

DataGrid Issue

Gary Blakely
Posts: n/a
(the following has also been posted to the datagrid Forum)
In the program below, the web page has dataGrid1. the only thing that has
been done to it at design time is to check the "Create columns automatically
at runtime" checkbox - nothing else.

The code below does indeed create the visual grid as expected. Furthermore
the Cell contents and Item count all exist and contain expected values.
However there is no columns array !! After the databind, for instance,
DataGrid1.Columns(0) does not exist. There is therefore, no way to even
reference the HeaderText (which visually shows) or any other attribute of
the column.

Why is this?

Public Class WebForm1
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim SQLStr As String = "Select FirstName, LastName From
Dim myConnection As New System.Data.SqlClient.SqlConnection
myConnection.ConnectionString = _
"workstation id=myMachine;user id=sa;data source=myMachine;" & _
"persist security info=True;initial
Dim cmd As New System.Data.SqlClient.SqlCommand(SQLStr,
Dim da As New System.Data.SqlClient.SqlDataAdapter
da.SelectCommand = cmd
Dim dt As New DataTable
DataGrid1.DataSource = dt

'at this point DataGrid1.Columns(0) does not exist
'DataGrid1.items(0).cells(0).text = "Nancy"
'DataGrid1.items.Count = 9

End If
End Sub

End Class

Gary Blakely
Dean Blakely & Associates

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Storage Issue (Basic Issue) Srini Java 11 06-01-2008 01:17 AM
Service Pack 2: login issue's and power management issue's ?!? Skybuck Flying Windows 64bit 0 04-07-2007 03:12 PM
inspiron 8200 video issue and hd issue the pez lover Computer Support 1 02-05-2007 02:44 AM
Major ActiveX Domain issue. NOT LOCAL PC ISSUE Computer Support 8 02-06-2006 09:03 PM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM