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. Data Grid hyperlink or Link button column

Data Grid hyperlink or Link button column

Scheduled Pinned Locked Moved ASP.NET
csshelptutorial
10 Posts 4 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.
  • D Offline
    D Offline
    Dotnetdeveloper06
    wrote on last edited by
    #1

    Hi I have doubt regarding Datagrid hyperlink column. Actually i will get my hyperlink url Dynamically in program when user selects items from dropdown boxes.so my URl will be something like this "\\servername\directoryname\Dropdownlist1.selecteditemvalue\variable\Dropdownlist2.selectedvaule" i m not getting how to dynamically set the navigate url to the hyperlink column in datagrid please help me hope its not confusing Thanks in advance Dotnetdeveloper06

    J J 2 Replies Last reply
    0
    • D Dotnetdeveloper06

      Hi I have doubt regarding Datagrid hyperlink column. Actually i will get my hyperlink url Dynamically in program when user selects items from dropdown boxes.so my URl will be something like this "\\servername\directoryname\Dropdownlist1.selecteditemvalue\variable\Dropdownlist2.selectedvaule" i m not getting how to dynamically set the navigate url to the hyperlink column in datagrid please help me hope its not confusing Thanks in advance Dotnetdeveloper06

      J Offline
      J Offline
      Javier Lozano
      wrote on last edited by
      #2

      could you explain a little bit better? ~Javier Lozano

      D 1 Reply Last reply
      0
      • J Javier Lozano

        could you explain a little bit better? ~Javier Lozano

        D Offline
        D Offline
        Dotnetdeveloper06
        wrote on last edited by
        #3

        Hi the application goes this way: I have to develop intranet application in such away that user can view PDF files in some folder in some server on the web page. For that PDF files, i have to get url dynamilcally. Actually i have 3 dropdownboxes RID,F,JN and BUtton.so when user selectes items in dropdownbox and click button he/she will get RID depending on selection condition. which will be dispalyed in datagrid. so inorder to open the PDFfile i need URL. so i will get URL depending on wat he selects in dropdownlist selections "\\servername\directoryname\F\variable\RID.PDf" AS i have used Datagrid to display RID from database so i used hyperlink as my next column.so now i have to get URLs for that RID in datagrid's first column. Hope u got . i tried to expalin. PLease help me. if u did not get i will try to exaplain again Thanks in adavance

        J R 2 Replies Last reply
        0
        • D Dotnetdeveloper06

          Hi the application goes this way: I have to develop intranet application in such away that user can view PDF files in some folder in some server on the web page. For that PDF files, i have to get url dynamilcally. Actually i have 3 dropdownboxes RID,F,JN and BUtton.so when user selectes items in dropdownbox and click button he/she will get RID depending on selection condition. which will be dispalyed in datagrid. so inorder to open the PDFfile i need URL. so i will get URL depending on wat he selects in dropdownlist selections "\\servername\directoryname\F\variable\RID.PDf" AS i have used Datagrid to display RID from database so i used hyperlink as my next column.so now i have to get URLs for that RID in datagrid's first column. Hope u got . i tried to expalin. PLease help me. if u did not get i will try to exaplain again Thanks in adavance

          J Offline
          J Offline
          Javier Lozano
          wrote on last edited by
          #4

          Two questions: 1) Why are you using a datagrid for this? 2) What does the page look like? ~Javier Lozano

          D 1 Reply Last reply
          0
          • J Javier Lozano

            Two questions: 1) Why are you using a datagrid for this? 2) What does the page look like? ~Javier Lozano

            D Offline
            D Offline
            Dotnetdeveloper06
            wrote on last edited by
            #5

            I m using datagrid b'coz i will get selected reportid vaules from Database on to page and they are dynamicall. and i cannot fix there vaule by using textbox or other contols. do u have any other to implement? please let me know thanks

            J 1 Reply Last reply
            0
            • D Dotnetdeveloper06

              I m using datagrid b'coz i will get selected reportid vaules from Database on to page and they are dynamicall. and i cannot fix there vaule by using textbox or other contols. do u have any other to implement? please let me know thanks

              J Offline
              J Offline
              Javier Lozano
              wrote on last edited by
              #6

              What about a repeater? Is there a particular way your data needs too look like? ~Javier Lozano

              1 Reply Last reply
              0
              • D Dotnetdeveloper06

                Hi the application goes this way: I have to develop intranet application in such away that user can view PDF files in some folder in some server on the web page. For that PDF files, i have to get url dynamilcally. Actually i have 3 dropdownboxes RID,F,JN and BUtton.so when user selectes items in dropdownbox and click button he/she will get RID depending on selection condition. which will be dispalyed in datagrid. so inorder to open the PDFfile i need URL. so i will get URL depending on wat he selects in dropdownlist selections "\\servername\directoryname\F\variable\RID.PDf" AS i have used Datagrid to display RID from database so i used hyperlink as my next column.so now i have to get URLs for that RID in datagrid's first column. Hope u got . i tried to expalin. PLease help me. if u did not get i will try to exaplain again Thanks in adavance

                R Offline
                R Offline
                rwestgraham
                wrote on last edited by
                #7

                Use the DataGrid_ItemDataBound event to configure the hyperlinks. The ItemDataBound event is raised every time a new rtow is added to a datagrid. You can access all the cells and/or embedded controls in the current row and use their values to concatenate a url. Example: Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound Dim dgItem As DataGridItem Dim hlMyLink As HyperLink If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then dgItem = CType(e.Item, DataGridItem) hlMyLink = CType(dgItem.FindControl("hlMyLink"), HyperLink) 'Read other cells or controls here to get url elements hlMyLink.NavigateUrl = End If End Sub

                D 1 Reply Last reply
                0
                • D Dotnetdeveloper06

                  Hi I have doubt regarding Datagrid hyperlink column. Actually i will get my hyperlink url Dynamically in program when user selects items from dropdown boxes.so my URl will be something like this "\\servername\directoryname\Dropdownlist1.selecteditemvalue\variable\Dropdownlist2.selectedvaule" i m not getting how to dynamically set the navigate url to the hyperlink column in datagrid please help me hope its not confusing Thanks in advance Dotnetdeveloper06

                  J Offline
                  J Offline
                  jinnyb
                  wrote on last edited by
                  #8

                  Solution that Mr.rwestgraham has given will defineitely help u out but for that u will have to bind the datagrid on every post back Hope u got the solution that i have given Bi JINNY Patel Neelesh A

                  1 Reply Last reply
                  0
                  • R rwestgraham

                    Use the DataGrid_ItemDataBound event to configure the hyperlinks. The ItemDataBound event is raised every time a new rtow is added to a datagrid. You can access all the cells and/or embedded controls in the current row and use their values to concatenate a url. Example: Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound Dim dgItem As DataGridItem Dim hlMyLink As HyperLink If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then dgItem = CType(e.Item, DataGridItem) hlMyLink = CType(dgItem.FindControl("hlMyLink"), HyperLink) 'Read other cells or controls here to get url elements hlMyLink.NavigateUrl = End If End Sub

                    D Offline
                    D Offline
                    Dotnetdeveloper06
                    wrote on last edited by
                    #9

                    Hi Thanks to all for ur replies. but i m getting this error when i m trying to run the app "Object reference not set to an instance of an object" and it showing at "Line 120: lMyLink.NavigateUrl = "\\aflarchive2\aflreports\" + DDLJN.SelectedValue + "\20050413\AFL" + DDLRID.SelectedValue" here is the code i mplemented Private Sub DataGrid2_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid2.ItemDataBound Dim dgItem As DataGridItem Dim hlMyLink As HyperLink If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then dgItem = CType(e.Item, DataGridItem) hlMyLink = CType(dgItem.FindControl("hlMyLink"), HyperLink) 'Read other cells or controls here to get url elements 'Dim Str As String = "\\aflarchive2\aflreports\" + DDLJN.SelectedValue + "\20050413\AFL" + DDLRID.SelectedValue hlMyLink.NavigateUrl = "\\aflarchive2\aflreports\" + DDLJN.SelectedValue + "\20050413\AFL" + DDLRID.SelectedValue End If Can u please help me how to fix it . Tahnku very much Dotnetprogramer

                    R 1 Reply Last reply
                    0
                    • D Dotnetdeveloper06

                      Hi Thanks to all for ur replies. but i m getting this error when i m trying to run the app "Object reference not set to an instance of an object" and it showing at "Line 120: lMyLink.NavigateUrl = "\\aflarchive2\aflreports\" + DDLJN.SelectedValue + "\20050413\AFL" + DDLRID.SelectedValue" here is the code i mplemented Private Sub DataGrid2_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid2.ItemDataBound Dim dgItem As DataGridItem Dim hlMyLink As HyperLink If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then dgItem = CType(e.Item, DataGridItem) hlMyLink = CType(dgItem.FindControl("hlMyLink"), HyperLink) 'Read other cells or controls here to get url elements 'Dim Str As String = "\\aflarchive2\aflreports\" + DDLJN.SelectedValue + "\20050413\AFL" + DDLRID.SelectedValue hlMyLink.NavigateUrl = "\\aflarchive2\aflreports\" + DDLJN.SelectedValue + "\20050413\AFL" + DDLRID.SelectedValue End If Can u please help me how to fix it . Tahnku very much Dotnetprogramer

                      R Offline
                      R Offline
                      rwestgraham
                      wrote on last edited by
                      #10

                      The ID of the Hyperlink control in the datagrid must match the string you are searching on in the FindControl method.

                      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