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. Getting value of a label after clicking on delete button in Gridvew

Getting value of a label after clicking on delete button in Gridvew

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

    Hi all, I would like to get the value of a label from the same row after clicking the delete button. I converted the delete button into a template field and tried the following code Dim a As String = "" a = CType(GridView1.FindControl("label1"), Label).Text It gives me an error saying that object reference not found, and use the NEW keyword to declare a new object instance. I tried declaring NEW on string but gives me an error. What should I do? Best Regards, Aaron Neo

    H 1 Reply Last reply
    0
    • A AaronNeo

      Hi all, I would like to get the value of a label from the same row after clicking the delete button. I converted the delete button into a template field and tried the following code Dim a As String = "" a = CType(GridView1.FindControl("label1"), Label).Text It gives me an error saying that object reference not found, and use the NEW keyword to declare a new object instance. I tried declaring NEW on string but gives me an error. What should I do? Best Regards, Aaron Neo

      H Offline
      H Offline
      Harini N K
      wrote on last edited by
      #2

      Hi Where did you put that code ?? If it is RowCommand Event of Gridview, you should set command name for the button. Try this... if (e.CommandName == "Insert") { Label lbl = (Label) e.FindControl('Label1'); String StrLabel = lbl.Text.ToString(); }

      Harini

      A 1 Reply Last reply
      0
      • H Harini N K

        Hi Where did you put that code ?? If it is RowCommand Event of Gridview, you should set command name for the button. Try this... if (e.CommandName == "Insert") { Label lbl = (Label) e.FindControl('Label1'); String StrLabel = lbl.Text.ToString(); }

        Harini

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

        Hi, Thank you so much for your reply. I tried your coding but it can't work. "Label is a type and cannot be used as an expression" I have converted the button into a template field. I have placed the codings in the button click event: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Best Regards, Aaron

        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