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. Don`t know whether its a bug in Gridviews empty data template

Don`t know whether its a bug in Gridviews empty data template

Scheduled Pinned Locked Moved ASP.NET
helphtmlcsswpfwcf
5 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.
  • W Offline
    W Offline
    www Developerof NET
    wrote on last edited by
    #1

    Hi all, I am finding a tough time solving this problem, but i am not able to understand this weird functionality. I have a grid view in my aspx as: After binding to gridview and in case no data is fetched, the grid doesn`t show up the empty data template. When i checked the html generated , the grid view is generated as

    There are no td tags generated.Where it should have been

    Sorry!!! No Records Available.

    what could be the problem:confused::confused::confused: When you fail to plan, you are planning to fail.

    S 1 Reply Last reply
    0
    • W www Developerof NET

      Hi all, I am finding a tough time solving this problem, but i am not able to understand this weird functionality. I have a grid view in my aspx as: After binding to gridview and in case no data is fetched, the grid doesn`t show up the empty data template. When i checked the html generated , the grid view is generated as

      There are no td tags generated.Where it should have been

      Sorry!!! No Records Available.

      what could be the problem:confused::confused::confused: When you fail to plan, you are planning to fail.

      S Offline
      S Offline
      samerh
      wrote on last edited by
      #2

      Are you sure you are binding the grid, if not bind the gridview with empty datatable and you can see the row. Dim dt As DataTable = Nothing Grv_Loc_wise_stk.DataSource = dt Grv_Loc_wise_stk.DataBind()

      W 1 Reply Last reply
      0
      • S samerh

        Are you sure you are binding the grid, if not bind the gridview with empty datatable and you can see the row. Dim dt As DataTable = Nothing Grv_Loc_wise_stk.DataSource = dt Grv_Loc_wise_stk.DataBind()

        W Offline
        W Offline
        www Developerof NET
        wrote on last edited by
        #3

        samerh wrote:

        Are you sure you are binding the grid,

        Yes, of course. If my filter criteria satisfies with the data being fetched, i can see it in my gridview.I am binding to a datatable which is filled from my sql database. ie something like this

        Grv_Loc_wise_stk.DataSource=sales.Get_Stock_data(item,frmdate,todate)
        Grv_Loc_wise_stk.DataBind()

        where Get_Stock_data returns a datatable.

        When you fail to plan, you are planning to fail.

        T 1 Reply Last reply
        0
        • W www Developerof NET

          samerh wrote:

          Are you sure you are binding the grid,

          Yes, of course. If my filter criteria satisfies with the data being fetched, i can see it in my gridview.I am binding to a datatable which is filled from my sql database. ie something like this

          Grv_Loc_wise_stk.DataSource=sales.Get_Stock_data(item,frmdate,todate)
          Grv_Loc_wise_stk.DataBind()

          where Get_Stock_data returns a datatable.

          When you fail to plan, you are planning to fail.

          T Offline
          T Offline
          tech603
          wrote on last edited by
          #4

          Your code is correct when i copied that code into my editor and ran it on an empty dataset it produced the desired results. My only theory is that sales.Get_Stock_data(item,frmdate,todate) is somehow is not empty or populated with null values giving the impression that its not empty. I would check that portion of your code because what you've posted is correct and works on my end. Hope that helps.

          Matthew Vass QA Analyst mvass@hostmysite.com HostMySite.com

          W 1 Reply Last reply
          0
          • T tech603

            Your code is correct when i copied that code into my editor and ran it on an empty dataset it produced the desired results. My only theory is that sales.Get_Stock_data(item,frmdate,todate) is somehow is not empty or populated with null values giving the impression that its not empty. I would check that portion of your code because what you've posted is correct and works on my end. Hope that helps.

            Matthew Vass QA Analyst mvass@hostmysite.com HostMySite.com

            W Offline
            W Offline
            www Developerof NET
            wrote on last edited by
            #5

            tech603 wrote:

            My only theory is that sales.Get_Stock_data(item,frmdate,todate) is somehow is not empty or populated with null values giving the impression that its not empty

            well i executed the procedure in my sql with the filter parameters and it returned me no rows. That suggests that my datatable is empty. Here`s what i have done in my function...

                 `   cmd = New SqlCommand             cmd.Connection = con             cmd.CommandText = "MyProc"             Adding Parameters....             cmd.Parameters.Add(.......             cmd.CommandType = CommandType.StoredProcedure             adp = New SqlDataAdapter             adp.SelectCommand = cmd             ds = New DataSet             adp.Fill(ds)             return ds.Tables(0)`
            

            I cant figure it out, where the problem is!!!!!!

            When you fail to plan, you are planning to fail.

            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