![]() |
DataGrid Issue
(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 Employees" Dim myConnection As New System.Data.SqlClient.SqlConnection myConnection.ConnectionString = _ "workstation id=myMachine;user id=sa;data source=myMachine;" & _ "persist security info=True;initial catalog=NorthWind;password=xxxxx" myConnection.Open() Dim cmd As New System.Data.SqlClient.SqlCommand(SQLStr, myConnection) Dim da As New System.Data.SqlClient.SqlDataAdapter da.SelectCommand = cmd Dim dt As New DataTable da.Fill(dt) DataGrid1.DataSource = dt DataGrid1.DataBind() 'at this point DataGrid1.Columns(0) does not exist 'however... 'DataGrid1.items(0).cells(0).text = "Nancy" 'DataGrid1.items.Count = 9 End If End Sub End Class -- Regards, Gary Blakely Dean Blakely & Associates www.deanblakely.com -- Regards, Gary Blakely Dean Blakely & Associates www.deanblakely.com |
| All times are GMT. The time now is 01:36 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.