[thelist] [ASP.NET] CHECKED attribute of radio button -- problem setting it within asp repeater

Jason Handby jasonh at corestar.co.uk
Thu Apr 14 05:08:12 CDT 2005


Hi all,


I have an asp repeater on my page. One of the things in it is a radio
button.

The HTML for my aspx page looks like this:

--------------------

      <asp:repeater id="rptMyList" runat="server">
      <HeaderTemplate>
            Here is a list:<br>
            <br>
            <table cellSpacing="0" cellPadding="0" width="240"
border="0">
                  <tr>
                        <td width="10">&nbsp;</td>
                        <td class="stext" style="FONT-WEIGHT: bold"
width="200">Name</td>
                        <td width="20">&nbsp;</td>
                        <td class="stext" style="FONT-WEIGHT: bold"
width="20">Active</td>
                  </tr>
      </HeaderTemplate>
      <ItemTemplate>
            <tr>
                  <td width="10">&nbsp;</td>
                  <td class="stext"><%#
DataBinder.Eval(Container.DataItem, "Name") %></td>
                  <td width="20">&nbsp;</td>
                  <td class="stext">
                        <input type="radio"
                        name='<%#
DataBinder.Eval(Container.DataItem, "ItemID") %>'
                        <%# DataBinder.Eval(Container.DataItem,
"IsActiveChecked") %> 
                        >
                  </td>
            </tr>
      </ItemTemplate>
      <FooterTemplate>
            </table>
            <br>
            <br>
      </FooterTemplate>
      </asp:repeater>

---------------------

In my dataset, which I am binding this repeater to, I have a column called
"IsActiveChecked", which will either contain the string "CHECKED" or the
string "" depending on whether I want the radio button checked. The code
I've written above works fine when you run it; the problem is that Visual
Studio .NET 2003 now refuses to let me edit my page in Design view. It
complains that my data bound field doesn't have quotes around it. The error
message I get is

      "Could not open in Design view. Place quotes around a '<% %>' block
used as an attribute value or within a <SELECT> element."

It seems that VS.NET 2003 can deal with you setting the *value* of an
attribute using data binding (e.g. the "name" attribute of my radio button)
but not actually creating the attribute itself.

Has anyone else encountered this problem? and if so, how did you resolve it?




Jason



More information about the thelist mailing list