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. Very Urgent....How to get the text value of Label placed in a DataList

Very Urgent....How to get the text value of Label placed in a DataList

Scheduled Pinned Locked Moved ASP.NET
csharphelptutorial
5 Posts 3 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.
  • F Offline
    F Offline
    Faisal Khatri
    wrote on last edited by
    #1

    Hi, I have a label control which is placed in DataList. The value of the label bounds using DataBinder.Eval...method. Now in the code of its ItemCommand i want to retrieve the value of the label. I know the process that used in VB.NET but dont know how it will be done in C#.. I did... string str=Convert.ChangeType(e.item.FindControl("lblName"),typeof(Label)).ToString(); But this line does not gets its Text value... Any one can help me plsss....... KHATRI

    _ K 2 Replies Last reply
    0
    • F Faisal Khatri

      Hi, I have a label control which is placed in DataList. The value of the label bounds using DataBinder.Eval...method. Now in the code of its ItemCommand i want to retrieve the value of the label. I know the process that used in VB.NET but dont know how it will be done in C#.. I did... string str=Convert.ChangeType(e.item.FindControl("lblName"),typeof(Label)).ToString(); But this line does not gets its Text value... Any one can help me plsss....... KHATRI

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      You can get that like this: string str=((label)e.item.FindControl("lblName")).Text :)

      Best Regards, Apurva Kaushal

      1 Reply Last reply
      0
      • F Faisal Khatri

        Hi, I have a label control which is placed in DataList. The value of the label bounds using DataBinder.Eval...method. Now in the code of its ItemCommand i want to retrieve the value of the label. I know the process that used in VB.NET but dont know how it will be done in C#.. I did... string str=Convert.ChangeType(e.item.FindControl("lblName"),typeof(Label)).ToString(); But this line does not gets its Text value... Any one can help me plsss....... KHATRI

        K Offline
        K Offline
        kitokatakito
        wrote on last edited by
        #3

        the line of code Convert.ChangeType(e.item.FindControl("lblName"),typeof(Label)) will return specific object with the specified system.type(Label) not the text of label so u can replace string str with Label object and then use it to get text so u can use this Label lbl=Convert.ChangeType(e.item.FindControl("lblName"),typeof(Label)); string requiredtext=lbl.Text i hope this will help

        F 1 Reply Last reply
        0
        • K kitokatakito

          the line of code Convert.ChangeType(e.item.FindControl("lblName"),typeof(Label)) will return specific object with the specified system.type(Label) not the text of label so u can replace string str with Label object and then use it to get text so u can use this Label lbl=Convert.ChangeType(e.item.FindControl("lblName"),typeof(Label)); string requiredtext=lbl.Text i hope this will help

          F Offline
          F Offline
          Faisal Khatri
          wrote on last edited by
          #4

          Well Mr kitokatakito I tried the way u told me but it doesnt work.. By the way now its working Thanks Apurva your way works... KHATRI

          _ 1 Reply Last reply
          0
          • F Faisal Khatri

            Well Mr kitokatakito I tried the way u told me but it doesnt work.. By the way now its working Thanks Apurva your way works... KHATRI

            _ Offline
            _ Offline
            _AK_
            wrote on last edited by
            #5

            always welcome.. :)

            Best Regards, Apurva Kaushal

            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