Data Repeater :: Can you?

M

mikeyatsony

Hi all...
I've been training a little on the whole ASP.NET and would like to know
how someone would use the data repeater like this:

For example, I have some data coming from a table and let's say for
some of the rows, I would like to show a website for the company if
they had that level of membership but for others, I would like to HIDE
the website for the company. It could be as easy as a BIT field in the
table like SHOWURL, if checked, it shows, if not, the URL should not
show.

Is there a way to do this? Do you use another control?

Thoughts?
 
K

Kevin Spencer

You can use a DataBinding expression that calls a custom function.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.
 
D

digitaljeebus

you could also hide the control in markup ... eg.
<asp:Label runat="server" id="lbl" visible="<%# Eval("AllowedToView")
%>" />

or control it via an ItemDataBound event handler

protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs
e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
WhateverYouBound ob = e.Item.DataItem as WhateverYouBound;
Label lbl = (Label)e.Item.FindControl("lbl");
lbl.Visible = ob.AllowedToView
}
}

sound good?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,832
Latest member
UtaHetrick

Latest Threads

Top