How to conditionally show a button in vb.net repeater


M

miaminemo

Guys -

I have my repeater working fine, but Im stuck on adding a button
conditionally to the repeater.

The repeater displays:
user,
questionAsked,
userAsked,
answer

I would like the repeater to have a 5th column populated with a button
that is visible only if the userAsked if the user currently running
the website.

i can add a button to the repeater but only for every row of the
repeater. I only want the button to be available when the user can
actually answer the question..

Here is my current code:
<asp:repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table border="1">
<tr bgcolor="DarkGray">
<th>Timestamp</th>
<th>UserID</th>
<th>Comment</th>
<th>Question</th>
<th>Response</th>
<th>Response Author</th>
<th>Response Date</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="#ffcccc">
<td><%# DataBinder.Eval(Container.DataItem, "commentDate")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "userID") %></
td>
<td><%# DataBinder.Eval(Container.DataItem, "comment") %></
td>
<td><%# DataBinder.Eval(Container.DataItem, "question") %></
td>
<td><%# DataBinder.Eval(Container.DataItem, "answer") %></
td>
<td><%# DataBinder.Eval(Container.DataItem, "answerUID") %></
td>
<td><%# DataBinder.Eval(Container.DataItem, "answerDate")
%></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr bgcolor="#ccff99">
<td><%# DataBinder.Eval(Container.DataItem, "commentDate")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "userID") %></
td>
<td><%# DataBinder.Eval(Container.DataItem, "comment") %></
td>
<td><%# DataBinder.Eval(Container.DataItem, "question") %></
td>
<td><%# DataBinder.Eval(Container.DataItem, "answer") %></
td>
<td><%# DataBinder.Eval(Container.DataItem, "answerUID") %></
td>
<td><%# DataBinder.Eval(Container.DataItem, "answerDate")
%></td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</TABLE>
</FooterTemplate> </asp:repeater>
 
Ad

Advertisements

S

sloan

You can follow the example here:

http://groups.google.com:80/group/microsoft.public.dotnet.general/msg/9738c9b0c5f2412f

and work it to the VISIBLE property of the button.

return a string of "true" or "false".

You pass in the information to the mini function.
You return a visible.

This is good for those little "mini business rule" situations like you
describe.

...

You might get another post about doing it more in-line, but I like the above
method...especially if your rule could possibly change.

...
 

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

Top