Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to show gridview with out data

how to show gridview with out data

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nettutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    findtango
    wrote on last edited by
    #1

    I'm returning a dataset to a gridview control. When the gridview asp.net control is populated from the returning dataset, if dataset is empty. The cells that are empty, in the gridview control, I would like to have the value of 0 (zero) inserted. So if no data is returned to that cell a 0 (zero) is shown.

    N M 2 Replies Last reply
    0
    • F findtango

      I'm returning a dataset to a gridview control. When the gridview asp.net control is populated from the returning dataset, if dataset is empty. The cells that are empty, in the gridview control, I would like to have the value of 0 (zero) inserted. So if no data is returned to that cell a 0 (zero) is shown.

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      First check the dataset is empty. If it is then add rows manually for the datatables. and bind that to the grid view.

      1 Reply Last reply
      0
      • F findtango

        I'm returning a dataset to a gridview control. When the gridview asp.net control is populated from the returning dataset, if dataset is empty. The cells that are empty, in the gridview control, I would like to have the value of 0 (zero) inserted. So if no data is returned to that cell a 0 (zero) is shown.

        M Offline
        M Offline
        manojch2
        wrote on last edited by
        #3

        Try This Protected Sub ItemDB(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Dim dv As DataView = CType(DataGrid1.DataSource, DataView) Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView) If dv.Table.Rows.Count = 0 Then 'By default the Datagrid Header is shown in case there is no Data Avaiable 'So in case of No Data found 'Check the ListItemType.Header If e.Item.ItemType = ListItemType.Header Then Dim i As Integer = e.Item.Cells.Count 'Assign "No Search result Found" in one of the cells of DataGrid e.Item.Cells(0).Text = "No Search Results Found" 'Remove Rest of the empty cells from Datagrid Dim j As Integer For j = i - 1 To 1 Step -1 e.Item.Cells.RemoveAt(j) Next End If End If End Sub '

        manojchilhate

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups