Using the DataBinder in clientside C# blocks.

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

Hi.

We use the <%# DataBinder.Eval
(Container.DataItem, "ColumnName") %> construct quite a
bit.

Is it possible to use this expression from a chunk of
client side code that isn't a data binding expression? For
example to display or hide a table row depending on one of
the values from the database.

For example:

<%
if(DataBinder.Eval(Container.DataItem, "ColumnName") ==
1)
{
%>
<tr><td>Special Offer!</td></tr>
<%
}
%>

I've tried using public strings from the server to the
client, but this breaks down when using them within a
repeater for many items.

Any suggestions would be welcome!

Thanks

Ben
 
I've worked around the problem now. I've made everything
runat=server (including table rows) and then I just set
visible=false in the code behind if it should be hidden.

It would still be good to know if it is possible to use
the DataBinder from a client side script block though.
 
Back
Top