Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / January 2005

Tip: Looking for answers? Try searching our database.

Datagrid Not Displaying

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roy - 24 Jan 2005 16:20 GMT
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
Roy - 24 Jan 2005 16:33 GMT
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>
Roy - 24 Jan 2005 16:53 GMT
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*
Roy - 24 Jan 2005 17:43 GMT
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."

;)
Mike Ryan - 24 Jan 2005 20:55 GMT
> 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). :)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.