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. Dynamic Div Creation?

Dynamic Div Creation?

Scheduled Pinned Locked Moved ASP.NET
phpdotnettutorialquestion
5 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.
  • F Offline
    F Offline
    Farraj
    wrote on last edited by
    #1

    Hello, I need some advices please. I'm trying to build a website for real estate listing. now the data would look like a datagrid. and while clicking on a row, it should open under it the dynamic data related to the specific row. (like an AJAX accordion). I will try to explain myself in a better way. this website for example ( ignore the language, couldnt find any better example LOL) http://www.yad2.co.il/Nadlan/rent.php Now, i've been told that this works by using "Dynamic Div Creation" which i have no idea how it should work this way. Is it possible to make it work by using an Accordion inside a datagrid? or what?!! If anybody can advice me or give me a sample code of doing such a thing i would be REALLY grateful.

    N 1 Reply Last reply
    0
    • F Farraj

      Hello, I need some advices please. I'm trying to build a website for real estate listing. now the data would look like a datagrid. and while clicking on a row, it should open under it the dynamic data related to the specific row. (like an AJAX accordion). I will try to explain myself in a better way. this website for example ( ignore the language, couldnt find any better example LOL) http://www.yad2.co.il/Nadlan/rent.php Now, i've been told that this works by using "Dynamic Div Creation" which i have no idea how it should work this way. Is it possible to make it work by using an Accordion inside a datagrid? or what?!! If anybody can advice me or give me a sample code of doing such a thing i would be REALLY grateful.

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      The accordion control is just a container, a div, for your controls so yes you can have anything you'd like there. Handle the client side click of the datagrid and make an ajax query for the data, populate the controls as necessary and expand the accordion.


      I know the language. I've read a book. - _Madmatt

      F 1 Reply Last reply
      0
      • N Not Active

        The accordion control is just a container, a div, for your controls so yes you can have anything you'd like there. Handle the client side click of the datagrid and make an ajax query for the data, populate the controls as necessary and expand the accordion.


        I know the language. I've read a book. - _Madmatt

        F Offline
        F Offline
        Farraj
        wrote on last edited by
        #3

        Hi Mark, i've reached this point, which is close but not what i want The JS code is :

        function toggleDivVisibility(id)
         {
            var divcontrol = document.getElementById(id);
            if (divcontrol.style.display == 'block')
                divcontrol.style.display = 'none';
            else
                divcontrol.style.display = 'block';
        }
        

        And Inside the ItemTemplate of the GridView, there is this code:

        < ItemTemplate >
        < a onclick = 'return void(0);' href="<%# DataBinder.Eval(Container,"RowIndex","javascript:toggleDivVisibility('Div{0}')") %>">

        More..

        // The code i wanted to show inside the div//
        < /div >

        This really does open a Div but the problem is that it opens it under the ItemTemplate(column) and not under the ROW. any ideas? Thanks

        N 1 Reply Last reply
        0
        • F Farraj

          Hi Mark, i've reached this point, which is close but not what i want The JS code is :

          function toggleDivVisibility(id)
           {
              var divcontrol = document.getElementById(id);
              if (divcontrol.style.display == 'block')
                  divcontrol.style.display = 'none';
              else
                  divcontrol.style.display = 'block';
          }
          

          And Inside the ItemTemplate of the GridView, there is this code:

          < ItemTemplate >
          < a onclick = 'return void(0);' href="<%# DataBinder.Eval(Container,"RowIndex","javascript:toggleDivVisibility('Div{0}')") %>">

          More..

          // The code i wanted to show inside the div//
          < /div >

          This really does open a Div but the problem is that it opens it under the ItemTemplate(column) and not under the ROW. any ideas? Thanks

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Of course it is in the cell, you're defining the template for it not the row. :rolleyes: What you need are controls like these http://samples.infragistics.com/2010.2/WebFeatureBrowser/Default.aspx[^] http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultcs.aspx[^] or build your own, which looking at the source for these samples should give you the idea. In this case a DataListView or Repeater may server your needs better than a DataGridView. Just because something is displayed in a grid doesn't mean you need to use a grid control.


          I know the language. I've read a book. - _Madmatt

          F 1 Reply Last reply
          0
          • N Not Active

            Of course it is in the cell, you're defining the template for it not the row. :rolleyes: What you need are controls like these http://samples.infragistics.com/2010.2/WebFeatureBrowser/Default.aspx[^] http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultcs.aspx[^] or build your own, which looking at the source for these samples should give you the idea. In this case a DataListView or Repeater may server your needs better than a DataGridView. Just because something is displayed in a grid doesn't mean you need to use a grid control.


            I know the language. I've read a book. - _Madmatt

            F Offline
            F Offline
            Farraj
            wrote on last edited by
            #5

            Thanks for the links, its useful. is there any way i can open it under the row at the same way im trying to do with a gridview?

            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