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

Jonathan R. Karlen jkarlen at infoniq.com
Thu Apr 14 08:15:12 CDT 2005


Have your dataset use either true or false rather than "CHECKED".

Then, do something like

Checked=<%# Container.DataItem("IsActiveChecked") %>


-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Jason Handby
Sent: Thursday, April 14, 2005 6:08 AM
To: thelist at lists.evolt.org
Subject: [thelist] [ASP.NET] CHECKED attribute of radio button -- problem
setting it within asp repeater


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

-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 



More information about the thelist mailing list