...

View Full Version : Label in Repeater



BrockLesnar
01-17-2005, 11:54 PM
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=)

Roelf
01-18-2005, 09:14 AM
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"

BrockLesnar
01-18-2005, 09:56 PM
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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum