473,785 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:CheckBoxLi st id=states runat=server>
</HeaderTemplate>
<ItemTemplate >
<asp:ListItem Value='<%# DataBinder.Eval (Container.Data Item,
"id")%>'><% # DataBinder.Eval (Container.Data Item, "name")%></asp:ListItem>
</ItemTemplate>
<FooterTemplate >
</asp:CheckBoxLis t>
</FooterTemplate>
</asp:datalist>

thanks
Nov 18 '05 #1
3 2885
Ed,
Just by looking at your example, why not simply bind to the checkboxlist?

states.DataSour ce = source
states.DataBind ()

?

Karl

"Ed West" <we**@westville .com> wrote in message
news:uh******** ******@TK2MSFTN GP12.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:CheckBoxLi st id=states runat=server>
</HeaderTemplate>
<ItemTemplate >
<asp:ListItem Value='<%# DataBinder.Eval (Container.Data Item,
"id")%>'><% # DataBinder.Eval (Container.Data Item, "name")%></asp:ListItem>
</ItemTemplate>
<FooterTemplate >
</asp:CheckBoxLis t>
</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_I temChanged 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.DataSour ce = source
states.DataBind ()

?

Karl

"Ed West" <we**@westville .com> wrote in message
news:uh******** ******@TK2MSFTN GP12.phx.gbl...
Hello

I am trying to put a CheckBoxList in a DataList but it's not working too
great. Is this possible?

<asp:datali st id=DataList1 runat="server" RepeatColumns=" 4">
<HeaderTempla te>
<asp:CheckBox List id=states runat=server>
</HeaderTemplate>
<ItemTemplate >
<asp:ListItem Value='<%# DataBinder.Eval (Container.Data Item,
"id")%>'><% # DataBinder.Eval (Container.Data Item, "name")%></asp:ListItem>
</ItemTemplate>
<FooterTempla te>
</asp:CheckBoxLis t>
</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("n ame"), row("id"))
if row("checked") = true then
li.selected = true
end if
states.Items.Ad d(li)
next

karl

"Ed West" <we**@westville .com> wrote in message
news:es******** ******@TK2MSFTN GP11.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_I temChanged 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.DataSour ce = source
states.DataBind ()

?

Karl

"Ed West" <we**@westville .com> wrote in message
news:uh******** ******@TK2MSFTN GP12.phx.gbl...
Hello

I am trying to put a CheckBoxList in a DataList but it's not working too
great. Is this possible?

<asp:datali st id=DataList1 runat="server" RepeatColumns=" 4">
<HeaderTempla te>
<asp:CheckBox List id=states runat=server>
</HeaderTemplate>
<ItemTemplate >
<asp:ListItem Value='<%# DataBinder.Eval (Container.Data Item,
"id")%>'><% # DataBinder.Eval (Container.Data Item, "name")%></asp:ListItem></ItemTemplate>
<FooterTempla te>
</asp:CheckBoxLis t>
</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
5672
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 carl.howarth@m-s-solutions.co.uk
2
2097
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:- checkboxlist1.DataSource = myDataSet Why?
5
13394
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 to get a Boolean value TRUE or FALSE when a checkBox is selected. When the checkBoxList was out of the DataList i used "OnSelectedIndexChanged" and it was returning what i wanted but if its in a
4
4043
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 work:( Thanks My CheckBoxList in the DataList Below
2
1008
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" OnSelectedIndexChanged="Check_Clicked"></asp:checkboxlist></ And the event that fires after when the checkBoxList is clicked ------------------------------------------------------- Sub Check_Clicked(ByVal sender As Object, ByVal e As EventArgs) Handles
0
1098
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. Everything works fine but when i tick a checkbox i get the error at line:- For i = 0 To checkboxlist1.Items.Count - 1 Object reference not set to an instance of an object.
4
2517
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 chkDebtor.DataValueField = "checked" -- this is a column in the table that returns 1 or 0 chkDebtor.DataTextField = "DebtorCode" chkDebtor.DataBind() Dim i As Integer = 0 While i < chkDebtor.Items.Count
1
2199
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 need to pull out of the page which products the user has selected. I have bound the products to the CheckboxList control in the ItemDataBound event for the Datalist. How can I extract what checkboxes have been selected inside the Datalist?
1
7940
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 the values that have been checked when the user submits the form. This code works as far as presentation goes but I can't seem to retrieve the checked values in the various checkboxlists that have been generated on the datalist's OnItemDataBound ...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10329
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8974
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.