Datagrid Not Displaying

R

Roy

Datagrid below. It will not display. The page shows nothing but the
html header. I have tested the query in query analyzer. Records exist
and should be displayed. I've stripped out all extraneous code to try
to narrow down where the syntactic flaw is but am still coming up
short. What am I missing here? I bet it's obvious... :-/



Option Strict On
imports Microsoft.VisualBasic
imports System
imports System.Data
imports System.Data.SqlClient
imports System.Web
imports System.Web.UI
imports System.Web.UI.WebControls
imports System.Web.UI.HtmlControls

Public Class Tier2Grid : Inherits System.Web.UI.Page

Protected DataGrid As System.Web.UI.WebControls.DataGrid
Dim MyConnection As SqlConnection
Dim gPoe As String
Dim gVoydoc As String

Public Sub Page_Load ( sender As Object, e As EventArgs )

IF (ISPOSTBACK = FALSE) THEN
BindData()
End If
End Sub

Public Sub BindData()

Dim DS As DataSet
Dim MyCommand As SqlDataAdapter

gPoe = Request.QueryString("poe")
gVoydoc = Request.QueryString("voydoc")
Dim SelectCmd As String = "SELECT TOP 500 IsNull(ocean_carrier_cd, '')
as 'Carrier'," _
& " IsNull(carrier_booking_nr, '') as 'Booking Num', IsNull(equipment,
'') as 'Equipment'," _
& " IsNull(Van_Owner, '') as 'Van Owner', IsNull(Tcon_Container_Num,'')
'Container Num', IsNull(Event_Code,'') as 'Event Code'," _
& " IsNull(Minof315_event_date,'') as 'Sail Date', IsNull(TCN,'') as
'TCN',IsNull(POD,'') as PoD," _
& " IsNull(Ship_Name,'') as 'Ship Name',IsNull(Pcfn,'') as
'PCFN',IsNull(LastEvent,'') as 'Last Event',IsNull(lasteventloc,'') as
'LE Location'," _
& " IsNull(LastEventdt,'') as 'LE Date',IsNull(Lastevent_shipname,'')
as 'LE Ship Name',IsNull(lastevent_scac,'') as 'LE SCAC'," _
& " IsNull(consigneecity,'') as 'Consignee City'" _
& " FROM firstvd WHERE voydoc = '"& gVoydoc & "' AND poe = '"& gPoe
&"'"

MyConnection = New
SqlConnection("server=localhost;uid=itv;pwd=itv_$ql!;database=maersk_test")
MyCommand = New SqlDataAdapter(SelectCmd, MyConnection)

DS = new DataSet()

MyCommand.Fill(DS)
DataGrid.DataSource = DS
DataGrid.DataBind()
Response.Write(SelectCmd)

End Sub

Sub DataGrid_EditCommand(Sender As Object, E As
DataGridCommandEventArgs)
DataGrid.EditItemIndex = CInt(E.Item.ItemIndex)
BindData()
End Sub

Sub DataGrid_CancelCommand(Sender As Object, E As
DataGridCommandEventArgs)
DataGrid.EditItemIndex = -1
BindData()
End Sub

Sub DataGrid_UpdateCommand(Sender As Object, E As
DataGridCommandEventArgs)

End Sub

End Class
 
R

Roy

Never mind. After 2 days of blank stares I naturally figure it out 5
minutes after posting it here. gah!
My .aspx page looked like the below example... my columns were outside
my grid. *rolling eyes at myself*
<asp:datagrid>
....
</asp:datagrid>
<columns>
....
</columns>
 
R

Roy

Hrmm....

Actually, refresh this question. Heh.
Now the page displays, but when I click edit, the datagrid vanishes.
IOW, the page refreshes, but the datagrid is not displayed. *sigh*
 
R

Roy

And scratch this one too. For those future .net newcomers who google
this in the future... try setting the enableviewstate property in your
datagrid to "true."

;)
 
M

Mike Ryan

For those future .net newcomers who google
this in the future... try setting the enableviewstate property in your
datagrid to "true."

Or the alternative with disabled viewstate: bind on every page load (not
just when PostBack is false). :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top