Saturday, March 24, 2012

Setting Text in 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)
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=)anyone?


b.Text = "At runtime I want the label to be this"

Is this what you are asking? If not then please give us some more detail.
I like Ferris Bueller too (anyone? anyone?)
When I do

Dim B as Label
B = e.FintControl("B")

B.Text = "Runtime"

Nothing happens, No errors nothing.

And when you do B = e.FindControl("B"), arent you actually making a replica of e.FindControl("B") and giving it to Dim B? If that is correct then B wouldnt show up on the page because it's not referenced?

Here's what I'm really trying to do
http://www.quiddity128.net/Articles/
In the database, I have the Link Name, Link Description etc.

I want to read the database and assign all the link names starting with B to the letter B. Same with every letter.

And before display the links, I want to display the Letter first, then the link as shown on http://www.quiddity128.net/Articles/

I want to know how to do it using repeaters because the current code i have is very messy

0 comments:

Post a Comment