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. how to use items in a formview

how to use items in a formview

Scheduled Pinned Locked Moved ASP.NET
helptutorial
4 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.
  • K Offline
    K Offline
    karanba
    wrote on last edited by
    #1

    hi all How could I reach a label in a formview edititemtemplate section void gogo(){ label01.Text="abc.."; // this gives error The name 'label01' does not exist in the current context } ... ... karanba

    F 1 Reply Last reply
    0
    • K karanba

      hi all How could I reach a label in a formview edititemtemplate section void gogo(){ label01.Text="abc.."; // this gives error The name 'label01' does not exist in the current context } ... ... karanba

      F Offline
      F Offline
      FionaDM
      wrote on last edited by
      #2

      You need to use FindControl for this. Try: protected void Button1_Click(object sender, EventArgs e) { Label MyLabel = null; MyLabel = (Label)FormView1.FindControl("label01"); MyLabel.Text= "xxxx"; } I'm just learning this stuff so it may not be the nicest way - but it should work. Maj

      K 1 Reply Last reply
      0
      • F FionaDM

        You need to use FindControl for this. Try: protected void Button1_Click(object sender, EventArgs e) { Label MyLabel = null; MyLabel = (Label)FormView1.FindControl("label01"); MyLabel.Text= "xxxx"; } I'm just learning this stuff so it may not be the nicest way - but it should work. Maj

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

        thaks this works...but I could not understand that why we can direcly reach any item that not nested in formview or any other control but this does not work in nested items ...:~ karanba -- modified at 14:37 Thursday 2nd February, 2006

        F 1 Reply Last reply
        0
        • K karanba

          thaks this works...but I could not understand that why we can direcly reach any item that not nested in formview or any other control but this does not work in nested items ...:~ karanba -- modified at 14:37 Thursday 2nd February, 2006

          F Offline
          F Offline
          FionaDM
          wrote on last edited by
          #4

          I can only imagine it's to avoid ambiguity. For example imagine FormView1 and FormView2 on the same page both with labels with ids of 'label01'. You couldn't access either without specifying which FormView you were targeting. Maj

          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