473,395 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

CheckboxList in DataList ?

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
Nov 18 '05 #1
3 2865
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

Nov 18 '05 #2

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


Nov 18 '05 #3
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


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Carl Howarth | last post by:
Hi, I have a check box list within a datalist. Can anybody tell me how I go about accessing the onclick event of these checkbox lists? (using vb.net) Many thanks, Carl Howarth...
2
by: Patrick.O.Ige | last post by:
Is it possible to bind a checkboxlist if this checkboxlist is in a datalist Bcos when i add a CheckBoxlist to a Datalist i get :- Object reference not set to an instance of an object error at:-...
5
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
2
by: Patrick Olurotimi Ige | last post by:
I have this checkboxlist out side a Datalist below:- <asp:checkboxlist id="chkList" AutoPostBack="True" Runat="server" DataValueField="ProductFeatureID" DataTextField="Feature"...
0
by: Patrick Olurotimi Ige | last post by:
I have a CheckBoxList(which is Databinded) in a Datalist. My DataBinded is done in the onItemDataBound I'm using this method below to select the selected item in a DataBinded CheckBoxList. ...
4
by: Patrick.O.Ige | last post by:
I'm DataBinding a CheckBoxList and i want to get the checkboxes selected when the page is loaded depending on a Boolean value from the Database.. chkDebtor.DataSource = objDR...
1
by: Mike | last post by:
I have a Datalist control on my page that I have binded to a table of available categories. In the Item Template I have a CheckboxList control bound to the products available in each Category. I...
1
by: terminul | last post by:
Hi I have a datalist which loops through the categories and within the datalist I have a CheckBoxList which are bound on the DataList's OnItemDataBound. The only problem I have is retrieving...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.