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. How to re-use one SqlDataSource for mutiple grids with different parameters

How to re-use one SqlDataSource for mutiple grids with different parameters

Scheduled Pinned Locked Moved ASP.NET
csstutorialquestion
2 Posts 2 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.
  • B Offline
    B Offline
    Brady Kelly
    wrote on last edited by
    #1

    I need to display four GridViews at once, but the data they contain differs in each grid by one parameter. It seems clumsy to add four identical SqlDataSource controls, so is there some way I can re-use one?

    A 1 Reply Last reply
    0
    • B Brady Kelly

      I need to display four GridViews at once, but the data they contain differs in each grid by one parameter. It seems clumsy to add four identical SqlDataSource controls, so is there some way I can re-use one?

      A Offline
      A Offline
      ashish bhakhar
      wrote on last edited by
      #2

      you can use stored procedure and bind one sqldatasource to that stored procedure. you can write down all the four queries with different parameters into your stored procedure using if loop instead of using four sqldatasources. for that you have to add one more parameter for identify the query from the loop. for example: @count int, @a varchar(50), @b varchar(50), @c varchar(50), @d varchar(50) if(@count=1) begin Query1 with parameter @a end if(@count=2) begin Query2 with parameter @b end if (@count=3) begin Query3 with parameter @c end if (@count=4) begin Query4 with parameter @d end

      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