display empty grid

Discussion in 'ASP .Net Datagrid Control' started by Nikhil Patel, Feb 18, 2004.

  1. Nikhil Patel

    Nikhil Patel Guest

    Hi,
    The grid is not displayed when it is bound to an empty dataset. I need to
    display just the header of the grid when the dataset is empty. How can I do
    this?

    Thanks...
    -Nikhil
     
    Nikhil Patel, Feb 18, 2004
    #1
    1. Advertising

  2. Dear Nikil

    I have same problem...please if u find answer of this qurey then tell me
    ... i will be thank ful to u?

    bye

    suresh

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    suresh kojhani, Feb 20, 2004
    #2
    1. Advertising

  3. Are you binding to a datatable or a dataset? The code below seems to product
    the header with no data:

    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Dim dt As New DataTable
    dt = CreateDataSource()
    If dt.Rows.Count = 0 Then
    End If
    DataGrid1.DataSource = dt
    DataGrid1.DataBind()
    End Sub
    Function CreateDataSource() As DataTable
    Dim dt As New DataTable
    Dim dr As DataRow
    dt.Columns.Add(New DataColumn _
    ("IntegerValue", GetType(Int32)))
    dt.Columns.Add(New DataColumn _
    ("StringValue", GetType(String)))
    dt.Columns.Add(New DataColumn _
    ("CurrencyValue", GetType(Double)))
    dt.Columns.Add(New DataColumn _
    ("Boolean", GetType(Boolean)))
    'Dim i As Integer
    'For i = 0 To 8
    ' dr = dt.NewRow()
    ' dr(0) = i
    ' dr(1) = "Item " + i.ToString()
    ' dr(2) = 1.23 * (i + 1)
    ' dr(3) = (i = 4)
    ' dt.Rows.Add(dr)
    'Next i
    Return dt
    End Function 'CreateDataSource

    "Nikhil Patel" <> wrote in message
    news:...
    > Hi,
    > The grid is not displayed when it is bound to an empty dataset. I need
    > to
    > display just the header of the grid when the dataset is empty. How can I
    > do
    > this?
    >
    > Thanks...
    > -Nikhil
    >
    >
     
    Ken Cox [Microsoft MVP], Feb 21, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John

    empty/non-empty element

    John, Jul 15, 2003, in forum: XML
    Replies:
    1
    Views:
    1,051
    Klaus Johannes Rusch
    Jul 16, 2003
  2. Lukas
    Replies:
    3
    Views:
    847
    spiff
    Nov 10, 2005
  3. Marcia Hon

    Check if a directory is empty and empty it

    Marcia Hon, Feb 8, 2004, in forum: C Programming
    Replies:
    8
    Views:
    598
    Dave Thompson
    Feb 14, 2004
  4. Brian Roberts

    empty lists vs empty generators

    Brian Roberts, May 3, 2005, in forum: Python
    Replies:
    12
    Views:
    676
    Jeremy Bowers
    May 4, 2005
  5. David Thielen

    Display an empty grid

    David Thielen, Oct 18, 2006, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    141
Loading...

Share This Page