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. General Programming
  3. LINQ
  4. Binding datasource to gridview as storedprocedure of DataContext object

Binding datasource to gridview as storedprocedure of DataContext object

Scheduled Pinned Locked Moved LINQ
databasewpfwcfhelp
6 Posts 2 Posters 6 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.
  • K Offline
    K Offline
    K V Sekhar
    wrote on last edited by
    #1

    Hi all, I have wrote a stored procedure to retrieve data fron Database. I added this stored procedure in .dbml file. I have assign the result of stored procedure to Gridview. I did like this Gridview1.DataSource = DataContextObj.StoredProcedureName(par1,par2,par3,par4); //All r input params only Gridview1.DataBind(); It returns nothing into Gridview. I think some thinhg went wrong in my code. There is nothing wrong in my StoredProcedure. I checked by passing parameters. It giving the result. Please help me.

    H 1 Reply Last reply
    0
    • K K V Sekhar

      Hi all, I have wrote a stored procedure to retrieve data fron Database. I added this stored procedure in .dbml file. I have assign the result of stored procedure to Gridview. I did like this Gridview1.DataSource = DataContextObj.StoredProcedureName(par1,par2,par3,par4); //All r input params only Gridview1.DataBind(); It returns nothing into Gridview. I think some thinhg went wrong in my code. There is nothing wrong in my StoredProcedure. I checked by passing parameters. It giving the result. Please help me.

      H Offline
      H Offline
      Howard Richards
      wrote on last edited by
      #2

      Have you set autogeneratecolumns = true in the gridview? Does the StoredProcedure return a specific type of object?

      'Howard

      K 1 Reply Last reply
      0
      • H Howard Richards

        Have you set autogeneratecolumns = true in the gridview? Does the StoredProcedure return a specific type of object?

        'Howard

        K Offline
        K Offline
        K V Sekhar
        wrote on last edited by
        #3

        Yes i set it to true.

        H 1 Reply Last reply
        0
        • K K V Sekhar

          Yes i set it to true.

          H Offline
          H Offline
          Howard Richards
          wrote on last edited by
          #4

          Try putting the stored procedure output in a temporary variable, and debug the code at that point to see if there is any data returned, before you assign to the .DataSource

          'Howard

          K 1 Reply Last reply
          0
          • H Howard Richards

            Try putting the stored procedure output in a temporary variable, and debug the code at that point to see if there is any data returned, before you assign to the .DataSource

            'Howard

            K Offline
            K Offline
            K V Sekhar
            wrote on last edited by
            #5

            Thanks for ur reply, I tried that one also. var temp = DataContextObj.SP_Name(par1,par2,par3); // Here i am getting '0', But when i execute my SP in SQL Management Studio i am getting records. Gridview1.DataSource = temp; Gridview1.DataBind(); any suggestions...

            H 1 Reply Last reply
            0
            • K K V Sekhar

              Thanks for ur reply, I tried that one also. var temp = DataContextObj.SP_Name(par1,par2,par3); // Here i am getting '0', But when i execute my SP in SQL Management Studio i am getting records. Gridview1.DataSource = temp; Gridview1.DataBind(); any suggestions...

              H Offline
              H Offline
              Howard Richards
              wrote on last edited by
              #6
              1. maybe the SP is returning the record count? 2) try delete and reimport the SP from the database to ensure the definition is correct

              'Howard

              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