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. Label giving problem

Label giving problem

Scheduled Pinned Locked Moved ASP.NET
debugginghelp
2 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.
  • B Offline
    B Offline
    bemahesh
    wrote on last edited by
    #1

    Dim SubHeader As String Dim dt As New DataTable dt = dst.Tables("MySubSections") Dim dr As DataRow Dim dc As DataColumn For Each dr In dt.Rows 'SubHeader = dst.Tables(0).Columns(0).ToString SubHeader = dr("MainPage").ToString Next Label4.Text = SubHeader THIS IS REPEATER I WANT LABEL TO BE DISPLAYED IN REPEATER Label IT IS GIVING NULL REFERENCE EXCEPTION. IF I DEBUG, I CAN SEE THE VALUE TO BE DISPLAYED IN VARIABLE “SubHeader” however, it gives me null reference exception Thanks Needy

    M 1 Reply Last reply
    0
    • B bemahesh

      Dim SubHeader As String Dim dt As New DataTable dt = dst.Tables("MySubSections") Dim dr As DataRow Dim dc As DataColumn For Each dr In dt.Rows 'SubHeader = dst.Tables(0).Columns(0).ToString SubHeader = dr("MainPage").ToString Next Label4.Text = SubHeader THIS IS REPEATER I WANT LABEL TO BE DISPLAYED IN REPEATER Label IT IS GIVING NULL REFERENCE EXCEPTION. IF I DEBUG, I CAN SEE THE VALUE TO BE DISPLAYED IN VARIABLE “SubHeader” however, it gives me null reference exception Thanks Needy

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, I guess the Label4 object is null, and you cannot access the Text property. How do you get reference to the label declared in the header of the repeater control? Because the Label is placed inside the repeater control, so you cannot simply add the declaration for the control in code-behind as you would with other controls placed in the web page. In this case, you can create an event handler for the ItemDataBound event of the repeater, then look for the label placed in the header item using the FindControl method. Once you have reference to to the label, you then can assign a value to the Text property.

      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