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
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Ed West" <we**@westville.com> wrote in message
news:Om**************@TK2MSFTNGP10.phx.gbl...
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