Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 23rd, 2005, 11:07 PM
Authorized User
 
Join Date: Feb 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot display datagrid on ASP webform

Hi,
     I have a ASP.Net 1.1 web form on which I have a Datagrid. When I run the application I get no error message but neither the grid nor the data appears. I put a Button for test and that button appears.

If I run the same code in VB.Net Windows Form everything works fine and the grid is populated with the data.

I am running this application on Windows 2000 Terminal Server IIS

Can someone please help. I am new to ASp.Net.

Thanks

 
Old February 23rd, 2005, 11:08 PM
Authorized User
 
Join Date: Feb 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

'This is my code for your reference.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

        Dim strConn As String
        Dim sSql As String = "select * from products"

        strConn = "Initial Catalog = NORTHWIND; data source = SYDBPW2K01;uid=;pwd=;Trusted_Connection=Yes"

        Dim cn As New SqlConnection
        cn.ConnectionString = strConn

        Dim adapter As New SqlDataAdapter(sSql, cn)
        Dim dSet As New DataSet

        adapter.Fill(dSet)

        Dim table As DataTable = dSet.Tables(0)

        DataGrid1.DataSource = table
    End Sub

 
Old February 24th, 2005, 06:10 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

FYI This is a classic ASP forum. Place .net posts in the .net area for the best assistance

Wind is your friend
Matt
 
Old February 24th, 2005, 06:43 PM
Authorized User
 
Join Date: Feb 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No worries, I worked it out myself anyway. Thanks

 
Old February 24th, 2005, 07:47 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Great. If you submit a problem then solve it, could you please post the solution? Then in future when others come accords the same problem, search this forum, finding the solution attached to the problem is very useful.

Wind is your friend
Matt
 
Old February 24th, 2005, 09:13 PM
Authorized User
 
Join Date: Feb 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, here is the solution.

After the line Datagrid1.Datasource = table just add Datagrid1.Databind()

One thing I have noticed is that if I am doing VB.Net then I do not need to say Datagrid1.Databind(), but this extra bit of code is required if I am doing ASP.Net

I am searching to find why Databind property is required for ASp.Net and NOT for VB.Net

Cheers.

 
Old March 11th, 2005, 09:12 AM
Authorized User
 
Join Date: Mar 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hy..
just make sure that after binding the datagrid,
u set it's visible property to 'True'





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.Net, Access DB, and a webform? TheNinthPlayer BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 8 June 3rd, 2008 10:28 AM
Display current date and time in a webform TextBox cesemj ASP.NET 2.0 Basics 4 October 22nd, 2007 04:07 PM
Accessing a Cell in a Webform Datagrid hexOffender VB.NET 2002/2003 Basics 1 December 28th, 2006 01:14 AM
How to retrive a value from DataGrid (WebForm) jkusmanto VB.NET 2002/2003 Basics 0 June 13th, 2006 02:47 AM
Cannot display Datagrid on ASP.Net smujib Classic ASP Databases 1 February 23rd, 2005 09:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.