Note that there are some explanatory texts on larger screens.

plurals
  1. POA tricky way to using <%# Bind %> in ASP.NET
    primarykey
    data
    text
    <p>In ASP.NET, I can use &lt;%# Bind %> to achieve two-way data binding, then the data source control can complete update function for me.</p> <p>However, I think it's only easy when you just show simple format, like</p> <pre><code>&lt;%# Bind("InsertDate") %&gt; </code></pre> <p>But, if I want to show 'N/A' when InsertDate is not exist. then how to use &lt;%# Bind %> to achieve the condition check?</p> <p>I know Bind function supports format string, like </p> <pre><code>&lt;%# Bind("InsertDate", "0:{dd MMM yyyy}") %&gt; </code></pre> <p>But it cannot change format base on InsertDate's content.</p> <p>I even try to use:</p> <pre><code>&lt;%# FormatString(Bind("InsertDate").ToString()) %&gt; </code></pre> <p>It seems's not working which normally works for Eval function.</p> <p>Another example is I have a bitwise column in table (like 5) which is represented by a checkboxlist wrapped by ListView control, like</p> <pre><code> &lt;asp:checkboxlist&gt; &lt;asp:ListItem value="1" text="OptionA"&gt; &lt;asp:ListItem value="2" text="OptionB"&gt; &lt;asp:ListItem value="4" text="OptionC"&gt; &lt;/asp:checkboxlist&gt; </code></pre> <p>then how to use &lt;%# Bind %> to achieve two-way bind to bind the bitwise column to this checkboxlist?</p> <p>Currently what I do is:</p> <ol> <li><p>set checkboxlist's selected item(value) in ListView's ItemDataBound event handler</p></li> <li><p>using a HiddenField and bind the data to this hiddenfield to achieve two-way data bind. </p></li> <li><p>In LivtView's ItemUpdating event handler, I update above ListViewUpdateEventArgs' NewValue property to the value I want. and then the EntityDataSource can do the update operation correctly.</p></li> </ol> <p>But I think this method is not easy and good.</p> <p>So is there any other better method to do this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload