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
  1. Home
  2. Web Development
  3. ASP.NET
  4. Grid View with null data

Grid View with null data

Scheduled Pinned Locked Moved ASP.NET
csharpcssasp-netdatabasewpf
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.
  • M Offline
    M Offline
    Member 4260270
    wrote on last edited by
    #1

    Hi all, I have a gridview control in asp.net 2.0,and some datas are binding from the database.If there is no data in the databse,then the grid is not displayed.Is it possible to display the grid without any data.The data is added by Thanks Denny

    P L 2 Replies Last reply
    0
    • M Member 4260270

      Hi all, I have a gridview control in asp.net 2.0,and some datas are binding from the database.If there is no data in the databse,then the grid is not displayed.Is it possible to display the grid without any data.The data is added by Thanks Denny

      P Offline
      P Offline
      padmanabhan N
      wrote on last edited by
      #2

      by assigning a empty datatabel with relevant column name can be useful. eg: DataTable dt = new DataTable(); dt.Columns.Add("dummy"); dt.Rows.Add(); GridView1.DataSource = dt; GridView1.DataBind(); //but this is not a best practise....

      Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

      1 Reply Last reply
      0
      • M Member 4260270

        Hi all, I have a gridview control in asp.net 2.0,and some datas are binding from the database.If there is no data in the databse,then the grid is not displayed.Is it possible to display the grid without any data.The data is added by Thanks Denny

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        < DataTable source = new DataTable(); gridViewAppointment.DataSource = source; // New empty row is added to the grid view to dis play the data table. source.Rows.Add(source.NewRow()); gridViewAppointment.DataBind(); int columnsCount = gridViewAppointment.Columns.Count; gridViewAppointment.Rows[0].Cells.Clear();// clear all the cells in the row gridViewAppointment.Rows[0].Cells.Add(new TableCell()); //add a new blank cell gridViewAppointment.Rows[0].Cells[0].ColumnSpan = columnsCount; gridViewAppointment.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; gridViewAppointment.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Red; gridViewAppointment.Rows[0].Cells[0].Font.Bold = true; // set No Results found to the new added cell gridViewAppointment.Rows[0].Cells[0].Text = "No Appointment Found!"; > yes it is possible but u have to display some message like no recordfound first create the data table bind it with grid view then get column count clear all cells then join all column through colspan then add text

        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