473,398 Members | 2,088 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,398 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 2867
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
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.