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. querystring in datalist template. + asp.net2.0 +c#

querystring in datalist template. + asp.net2.0 +c#

Scheduled Pinned Locked Moved ASP.NET
csharpquestionasp-netdatabasehelp
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.
  • R Offline
    R Offline
    regin
    wrote on last edited by
    #1

    i have a datalist template hyperlink..if i click on tat i have to pass a query string to the response page... the query string is a dynamic one... for eg if im displaying a user name n password in the datalist i have to pass userid as querystring of the corresponding selected username.. how can i do tat??\plz help me out.

    C 1 Reply Last reply
    0
    • R regin

      i have a datalist template hyperlink..if i click on tat i have to pass a query string to the response page... the query string is a dynamic one... for eg if im displaying a user name n password in the datalist i have to pass userid as querystring of the corresponding selected username.. how can i do tat??\plz help me out.

      C Offline
      C Offline
      Chetan Ranpariya
      wrote on last edited by
      #2

      Hi, I could not find any direct way to do this. But u can use ItemDataBound event of datalist. U need to put hyperlink in datalist ItemTemplate without setting its NavigateUrl property. This property u can set at runtime while datalist it bound to the datasource. Your hyperlink should be like following. I have put one label control which will have the value which we want make querystring. I have set its visible property = false; now I am setting hyperlink's navigateurl property in ItemDataBound event of datalist. protected void dlst_ItemDataBound ( object sender, DataListItemEventArgs e ) { HyperLink hl = ( HyperLink )e.Item.FindControl( "HyperLink1" ); Label lbl = ( Label )e.Item.FindControl( "lblusernamehidden" ); if ( hl != null && lbl != null ) { hl.NavigateUrl = "~/TargetPage.aspx?username=" + lbl.Text; } } this way you can get querystring dynamically in hyperlink. also set Datalist's OnItemDataBound property to "dlst_ItemDataBound". I hope this will help you. Thanks and Regards, Chetan Ranpariya

      R 1 Reply Last reply
      0
      • C Chetan Ranpariya

        Hi, I could not find any direct way to do this. But u can use ItemDataBound event of datalist. U need to put hyperlink in datalist ItemTemplate without setting its NavigateUrl property. This property u can set at runtime while datalist it bound to the datasource. Your hyperlink should be like following. I have put one label control which will have the value which we want make querystring. I have set its visible property = false; now I am setting hyperlink's navigateurl property in ItemDataBound event of datalist. protected void dlst_ItemDataBound ( object sender, DataListItemEventArgs e ) { HyperLink hl = ( HyperLink )e.Item.FindControl( "HyperLink1" ); Label lbl = ( Label )e.Item.FindControl( "lblusernamehidden" ); if ( hl != null && lbl != null ) { hl.NavigateUrl = "~/TargetPage.aspx?username=" + lbl.Text; } } this way you can get querystring dynamically in hyperlink. also set Datalist's OnItemDataBound property to "dlst_ItemDataBound". I hope this will help you. Thanks and Regards, Chetan Ranpariya

        R Offline
        R Offline
        regin
        wrote on last edited by
        #3

        thank you...its working.....

        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