Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-17-2005, 10:54 PM   PM User | #1
BrockLesnar
New Coder

 
Join Date: Jan 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
BrockLesnar is an unknown quantity at this point
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=)
BrockLesnar is offline   Reply With Quote
Old 01-18-2005, 08:14 AM   PM User | #2
Roelf
Senior Coder

 
Join Date: Jun 2002
Location: Zwolle, The Netherlands
Posts: 1,110
Thanks: 2
Thanked 28 Times in 28 Posts
Roelf is on a distinguished road
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"
Roelf is offline   Reply With Quote
Old 01-18-2005, 08:56 PM   PM User | #3
BrockLesnar
New Coder

 
Join Date: Jan 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
BrockLesnar is an unknown quantity at this point
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?
BrockLesnar is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:51 PM.


Advertisement
Log in to turn off these ads.