Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Label in Repeater

    I have a Repeater Control with a Label in the <SeperatorTemplate> of the Repeater.

    I want to set the text in the label at runtime. How do I do this?

    What I have so far

    Sub rp2_ItemCreated(Sender As Object, e As RepeaterItemEventArgs)
    dim b as label
    t = left(DataBinder.Eval(e.Item.DataItem, "Title"),1)
    if not prev = t then
    b = (CType(e.Item.FindControl("lbl_linkstarter"), Label)) <--This retrieves the text from the label in the repeater
    prev = t
    end if

    end sub

    Now that retrieves the text, but how do i set the text?

    Iam very new to repeaters and stuff so go easy on me hehe=)

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    afaik, the b variable holds the label control after the command you pointed at, so you must be able to do something like b.Text = "yourtext"
    I am the luckiest man in the world

  • #3
    New Coder
    Join Date
    Jan 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sub rp2_ItemCreated(Sender As Object, e As RepeaterItemEventArgs)
    Dim objItem As RepeaterItem
    Dim objLabel As TextBox
    For Each objItem In rp2.Items
    Select Case objItem.ItemType
    Case ListItemType.AlternatingItem, ListItemType.Item, ListItemType.SelectedItem
    objLabel = CType(objItem.FindControl("lbl_linkstarter"), Textbox)
    objLabel.Text = "adfs"
    End Select
    Next
    response.write(objLabel)
    t = left(DataBinder.Eval(e.Item.DataItem, "Title"),1)
    if not prev = t then
    if not objLabel is Nothing then
    objLabel.Text = "213123"
    end if
    prev = t
    end if

    I changed the code a bit

    Still when I try to assign the text to it, i get a error
    the error is:
    objLabel.Text = "adfs"
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Also if I assign the text like
    objLabel.Text = "adfs"
    its asigning the text to a replica objLabel instead of the actual label in the repeater isnt it?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •