2 Replies - 1317 Views - Last Post: 14 January 2014 - 10:31 PM Rate Topic: -----

#1 evadkram  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 14-August 09

No data display in gridview

Posted 12 January 2014 - 11:10 PM

i search all of the possible codes but it doesnt display the data.. i used asp.net 4.0 using vb.net..
i have a gridview in my webform, when i run it the datagridview doesnt display any data from the query.. is there configuration in the gridview template properties i will change?? im also using visual studio 2012 and sql server 2012.. this is my code and this is my first time handling asp.net gridview control. i already set my boundfield

Imports System.Data
Imports System.Data.SqlClient

Partial Class forApproval
    Inherits System.Web.UI.Page

    Dim con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("WorkRequestConnectionString").ConnectionString)
    Dim cmd As New SqlCommand
    Dim sqlstr As String


    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
          
            sqlstr = "SELECT ReqBy, ReqDate, CompanyName, DeptName, SwModule, TechWorks, TechWorksOthers, AffectdProcess, WorkStatus FROM tblWorkRequest"

            Dim cmd As New SqlCommand(sqlstr, con)
            Dim da As New SqlDataAdapter(cmd)
            Dim ds As New DataSet
            
            da.Fill(ds)
            If (ds.Tables.Count > 0) Then

                GridView1.DataSource = ds
                GridView1.DataBind()
            End If
          
        End If
    End Sub



End Class

This post has been edited by modi123_1: 13 January 2014 - 10:08 AM
Reason for edit:: please use the code tags


Is This A Good Question/Topic? 0
  • +

Replies To: No data display in gridview

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9201
  • View blog
  • Posts: 34,576
  • Joined: 12-June 08

Re: No data display in gridview

Posted 13 January 2014 - 10:10 AM

Did you set your HTML code up right?
http://msdn.microsof...e/cc163933.aspx
Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1055
  • View blog
  • Posts: 4,085
  • Joined: 02-July 08

Re: No data display in gridview

Posted 14 January 2014 - 10:31 PM

The GridView is expecting a DataTable to be bound to and not the DataSet.

GridView1.DataSource = ds.Tables(0)

This post has been edited by _HAWK_: 14 January 2014 - 10:31 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1