Search code examples
asp.netgridviewaspx-user-control

if statement in aspx page


attempting to set a radio button on a grid view via a condition.

 <input name="MyRadioButton" id="MyRadioButton<%=RadioNum() %>" type="radio" value='<%# Eval("TCMD_DCMNT_NBR") & Eval("VNDR_RQST_NBR") %>' style="left:auto" <% Eval("IsPostBack") {checked="checked"} {} %> /> 
                    <label for="MyRadioButton<%=RadioNumLabel() %>" style="display:none;"><%# Eval("TCMD_DCMNT_NBR") & Eval("VNDR_RQST_NBR") %></label>
                </ItemTemplate>

not quite sure how to set the checked to true when my IsPostBack is true.

thanks


Solution

  • If I remember correctly, you should be able to reference the Page.IsPostBack property directly to set your attribute using a simple ternary operator :

    <%= Page.IsPostBack ? "checked='checked'" : "" %>