Could not open in Design view. Place quotes around a <% %>

E

Ed West

Am getting this error with the following code, particularly this line:

<%# Check(DataBinder.Eval(Container.DataItem, "broker_id"))%>

I am creating checkboxes and the Check function checks to have that
particular checkbox checked by default. I am not using checkboxlist
because I want to EASILY save data to DB with a comma separated list
which HTML gives you if all the checkboxes have the same name.

<asp:datalist id=DataList1 runat="server" RepeatColumns="4">
<ItemTemplate>
<INPUT type=checkbox name=state_ids id='state_id_<%#
DataBinder.Eval(Container.DataItem, "id")%>' value='<%#
DataBinder.Eval(Container.DataItem, "id")%>' <%#
Check(DataBinder.Eval(Container.DataItem, "broker_id"))%> > <%#
DataBinder.Eval(Container.DataItem, "name")%>
</ItemTemplate>
</asp:datalist>

protected string Check(object x) {
if (x != DBNull.Value)
return(" CHECKED");
else
return("");
}

any ideas?

thanks

-ed
 
K

Karl

The only way to make it work is to change your input type="checkbox into an
<asp:checkbox, use checked='<%# Check(DataBinder.Eval(Container.DataItem,
"broker_id"))%>' and change your function to return true/false

karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top