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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. highlight the selected row in the the Nested gridview.

highlight the selected row in the the Nested gridview.

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

    I took advantage of some code I found on these forums and have created a form that has a nested gridview. The first gridview is bound using the SqlDataSource and on the OnRowBound event, bind data to the nested gridview. Then using JavaScript i hide the nested gridview until the user clicks on an image. The code I found for the javascript nested grid view is here. I then added code to highlight the selected row in the the first gridview. What i need to know is how would I go about adding code to make it so that I can do the same for the nested gridview? Sample code protected void Page_PreRenderComplete(object sender, System.EventArgs e) { //GridView nestedGrid = (GridView)GridView1.FindControl("GridView2"); foreach (GridViewRow y in GridView1.Rows) { y.Attributes.Add("onclick", "setSelected(this);"); } } function setSelected(selRow) { // alert(selRow.rowIndex); var tbl = document.getElementById("GridView1"); for(var i = 1; i < tbl.rows.length; i++) { if(selRow.rowIndex == i) { selRow.style.fontWeight = "Bold"; selRow.style.backgroundColor = "Yellow"; } } } But once i moved to child grid that time Click event of parent Grid cell does not fired so all highlited row of parent grid gone. so how to solve it Raghvendra

    Raghvendra

    A 1 Reply Last reply
    0
    • M Member 4659001

      I took advantage of some code I found on these forums and have created a form that has a nested gridview. The first gridview is bound using the SqlDataSource and on the OnRowBound event, bind data to the nested gridview. Then using JavaScript i hide the nested gridview until the user clicks on an image. The code I found for the javascript nested grid view is here. I then added code to highlight the selected row in the the first gridview. What i need to know is how would I go about adding code to make it so that I can do the same for the nested gridview? Sample code protected void Page_PreRenderComplete(object sender, System.EventArgs e) { //GridView nestedGrid = (GridView)GridView1.FindControl("GridView2"); foreach (GridViewRow y in GridView1.Rows) { y.Attributes.Add("onclick", "setSelected(this);"); } } function setSelected(selRow) { // alert(selRow.rowIndex); var tbl = document.getElementById("GridView1"); for(var i = 1; i < tbl.rows.length; i++) { if(selRow.rowIndex == i) { selRow.style.fontWeight = "Bold"; selRow.style.backgroundColor = "Yellow"; } } } But once i moved to child grid that time Click event of parent Grid cell does not fired so all highlited row of parent grid gone. so how to solve it Raghvendra

      Raghvendra

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Please don't cross post. If you posted the same question, before few hours back. X|

      cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net View My Recent Article

      M 1 Reply Last reply
      0
      • A Abhijit Jana

        Please don't cross post. If you posted the same question, before few hours back. X|

        cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net View My Recent Article

        M Offline
        M Offline
        Member 4659001
        wrote on last edited by
        #3

        OK Next time i will take care , but i request u to ans my problem if no one else

        Raghvendra

        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