There's no simple way, the best is to loop through your datasource and set
the fields..but if you are going to do that, forget the databinding:
for each row as DataRow in DataTable
dim li as new ListItem(row("name"), row("id"))
if row("checked") = true then
li.selected = true
end if
states.Items.Add(li)
next
karl
"Ed West" <we**@westville.com> wrote in message
news:es**************@TK2MSFTNGP11.phx.gbl...
Oh yeah, good idea. Didn't know I could do that. I also might want to
set some of the items to checked if a field in the query is checked, can
I do a CheckBoxList1_ItemChanged event or something to set checked=true
if another field in that query row is not null? If so, how can i do
that exactly?
thanks,
-ed
Karl wrote:
Ed,
Just by looking at your example, why not simply bind to the
checkboxlist?
states.DataSource = source
states.DataBind()
?
Karl
"Ed West" <we**@westville.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl...
Hello
I am trying to put a CheckBoxList in a DataList but it's not working too
great. Is this possible?
<asp:datalist id=DataList1 runat="server" RepeatColumns="4">
<HeaderTemplate>
<asp:CheckBoxList id=states runat=server>
</HeaderTemplate>
<ItemTemplate>
<asp:ListItem Value='<%# DataBinder.Eval(Container.DataItem,
"id")%>'><%# DataBinder.Eval(Container.DataItem,
"name")%></asp:ListItem></ItemTemplate>
<FooterTemplate>
</asp:CheckBoxList>
</FooterTemplate>
</asp:datalist>
thanks