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. Get the first and last row for each child row

Get the first and last row for each child row

Scheduled Pinned Locked Moved ASP.NET
csharpcssasp-nethelptutorial
6 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.
  • A Offline
    A Offline
    AsianRogueOne
    wrote on last edited by
    #1

    Hi All, I am a newbie to ASP.NET and in need of you help, basically, I have a gridview that binded from two functions (type datatable). One function is parent which I past one parameter ("DeptID") while loading this table I also called the child funtion which get the parameter from the parent function ("FolderID"). The grid bind fine, but my tast is to place a down arrow at the first child row under the parent and an a up arrow at the last child row and the process repeated for each parent that have one or more rows. This is where I have been banging head head trying to get this work but has no success. Parent row data1 Down arrow Child row data - first row up/down arrow Child row data up/down arrow Child row data up/down arrow Child row data up arrow Child row data - last row Parent row data2 Down arrow Child row data - first row up/down arrow Child row data up/down arrow Child row data up arrow Child row data - last row Parent row data3 Down arrow Child row data - first row up/down arrow Child row data up arrow Child row data - last row Parent row data4 Child row data - first row Any assistance is greatly apprecaited. please provide codes example. Thanks DocHoliday. Here are my codes behind VB: Protected Sub DisplayParentGV() Dim Conn As New SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings("mConn").ToString) Dim SQLCmd As New SqlCommand("Get_Links_Name", conn) Dim SQLDBDataReader As SqlClient.SqlDataReader Dim dt As New DataTable() Try If conn.State = ConnectionState.Closed Then conn.Open() End If SQLCmd.CommandType = CommandType.StoredProcedure SQLCmd.Connection = conn SQLCmd.Parameters.Add("@DeptID", SqlDbType.Int, 60).Value = Convert.ToInt32(Session("Dept_id")) dt.Columns.Add(New DataColumn("FolderID", GetType(String))) dt.Columns.Add(New DataColumn("FolderFileID", GetType(String))) dt.Columns.Add(New DataColumn("ImageType", GetType(String))) dt.Columns.Add(New DataColumn("Page", GetType(String))) dt.Columns.Add(New DataColumn("FolderOrder", GetType(String))) dt.Columns.Add(New DataColumn("Link_FileOrder", GetType(String))) SQLDBDataReader = SQLCmd.ExecuteReader() While SQLDBDataReader.Read() Dim dr As DataRow = dt.NewRow() Di

    A 1 Reply Last reply
    0
    • A AsianRogueOne

      Hi All, I am a newbie to ASP.NET and in need of you help, basically, I have a gridview that binded from two functions (type datatable). One function is parent which I past one parameter ("DeptID") while loading this table I also called the child funtion which get the parameter from the parent function ("FolderID"). The grid bind fine, but my tast is to place a down arrow at the first child row under the parent and an a up arrow at the last child row and the process repeated for each parent that have one or more rows. This is where I have been banging head head trying to get this work but has no success. Parent row data1 Down arrow Child row data - first row up/down arrow Child row data up/down arrow Child row data up/down arrow Child row data up arrow Child row data - last row Parent row data2 Down arrow Child row data - first row up/down arrow Child row data up/down arrow Child row data up arrow Child row data - last row Parent row data3 Down arrow Child row data - first row up/down arrow Child row data up arrow Child row data - last row Parent row data4 Child row data - first row Any assistance is greatly apprecaited. please provide codes example. Thanks DocHoliday. Here are my codes behind VB: Protected Sub DisplayParentGV() Dim Conn As New SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings("mConn").ToString) Dim SQLCmd As New SqlCommand("Get_Links_Name", conn) Dim SQLDBDataReader As SqlClient.SqlDataReader Dim dt As New DataTable() Try If conn.State = ConnectionState.Closed Then conn.Open() End If SQLCmd.CommandType = CommandType.StoredProcedure SQLCmd.Connection = conn SQLCmd.Parameters.Add("@DeptID", SqlDbType.Int, 60).Value = Convert.ToInt32(Session("Dept_id")) dt.Columns.Add(New DataColumn("FolderID", GetType(String))) dt.Columns.Add(New DataColumn("FolderFileID", GetType(String))) dt.Columns.Add(New DataColumn("ImageType", GetType(String))) dt.Columns.Add(New DataColumn("Page", GetType(String))) dt.Columns.Add(New DataColumn("FolderOrder", GetType(String))) dt.Columns.Add(New DataColumn("Link_FileOrder", GetType(String))) SQLDBDataReader = SQLCmd.ExecuteReader() While SQLDBDataReader.Read() Dim dr As DataRow = dt.NewRow() Di

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Why do you require to deal with first and last row when you can easily do this using You might consider asp:repeater which already has HeaderTemplate and FooterTemplate to deal with just this. :thumbsup:

      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


      My Latest Articles-->** Simplify Code Using NDepend
      Basics of Bing Search API using .NET
      Microsoft Bing MAP using Javascript

      A 2 Replies Last reply
      0
      • A Abhishek Sur

        Why do you require to deal with first and last row when you can easily do this using You might consider asp:repeater which already has HeaderTemplate and FooterTemplate to deal with just this. :thumbsup:

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->** Simplify Code Using NDepend
        Basics of Bing Search API using .NET
        Microsoft Bing MAP using Javascript

        A Offline
        A Offline
        AsianRogueOne
        wrote on last edited by
        #3

        Does repeater have the same function as gridview does ?

        1 Reply Last reply
        0
        • A Abhishek Sur

          Why do you require to deal with first and last row when you can easily do this using You might consider asp:repeater which already has HeaderTemplate and FooterTemplate to deal with just this. :thumbsup:

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          My Latest Articles-->** Simplify Code Using NDepend
          Basics of Bing Search API using .NET
          Microsoft Bing MAP using Javascript

          A Offline
          A Offline
          AsianRogueOne
          wrote on last edited by
          #4

          I need to get the first and last row because my page allow user to move the order of the child row up/down. Therefore, if the child row is first row then user cannot move it up and same for last row, user cannot move it down.

          A 1 Reply Last reply
          0
          • A AsianRogueOne

            I need to get the first and last row because my page allow user to move the order of the child row up/down. Therefore, if the child row is first row then user cannot move it up and same for last row, user cannot move it down.

            A Offline
            A Offline
            Abhishek Sur
            wrote on last edited by
            #5

            Yes ... Repeater has that option. Acutally everything in repeater is created by you. Just use PageDataSource to handle paging. Place values in ViewState and use HeaderTemplate and FooterTemplate to have first and last row. You might give it a try... :rose:

            Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


            My Latest Articles-->** Simplify Code Using NDepend
            Basics of Bing Search API using .NET
            Microsoft Bing MAP using Javascript

            A 1 Reply Last reply
            0
            • A Abhishek Sur

              Yes ... Repeater has that option. Acutally everything in repeater is created by you. Just use PageDataSource to handle paging. Place values in ViewState and use HeaderTemplate and FooterTemplate to have first and last row. You might give it a try... :rose:

              Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


              My Latest Articles-->** Simplify Code Using NDepend
              Basics of Bing Search API using .NET
              Microsoft Bing MAP using Javascript

              A Offline
              A Offline
              AsianRogueOne
              wrote on last edited by
              #6

              Thanks

              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