Repeater - checking for null values

J

Jason

I am using a repeater to display my search results (see
snippet below). If the DataItem is null, I don't want to
display the hyperlink text (Open Survey). Can I do an
If..Then right in the aspx page to check for a null or
blank value? I would much rather do this in the code-
behind if possible.
....
<td><asp:HyperLink NavigateUrl='<%# Databinder.Eval
(Container.DataItem, "Survey") %>' Runat="server"
ID="hypSurvey">Open Survey</asp:HyperLink></td>
....

Thanks.
 
K

Karl Seguin

Jason,
You should/can do this in codebehind, hook into the ItemDataBound event of
the repeater, it'll fire for each <itemTemplate> you'll have access to
e.Item.DataItem which you can cast to a DataRowView (my guess is that's what
you need). At that point you can access your fields, like

HyperLink h = (HyperLink) e.item.FindControl("hypSurvey");
h.visible = false;

or something similar..

Karl
 

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

Similar Threads

repeater 0
Repeater - If..Then 2
asp:hyperlink object in Repeater control ?? 4
repeater 3
Hyperlink Rollover images in Repeater error 5
Repeater question 4
repeater/hyperlink & dbNULL ?? 0
Hyperlink\HTML Table 2

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top