Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to add DataBinded CheckBoxList in Datalist

Reply
Thread Tools

How to add DataBinded CheckBoxList in Datalist

 
 
=?Utf-8?B?UGF0cmljay5PLklnZQ==?=
Guest
Posts: n/a
 
      06-17-2005
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?
 
Reply With Quote
 
 
 
 
Jeremy S
Guest
Posts: n/a
 
      06-17-2005
You might try a variation of the code below.
Basically as each row is DataBound to your DataList, you do whatever you
must with the controls in your item template. In the code below there is a
button (btnDeleteThis) to which I'm adding an attribute. I suspect this
could be easily modified to find your CheckBox list. So, it may be as simply
as adjusting the following code. Sorry I'm under the gun on a project to
convert this to VB for you - but it should show you what needs to be done.

The first line creates a reference to the object (a button in my case, buta
CheckBoxList in your case) via FindControl.

If that first line worked (the object reference is not null), then you can
proceed to databind your CheckBoxlist (inside the IF structure).


private void MyDataList_ItemDataBound(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e) {
Button curButton = (Button)e.Item.FindControl("btnDeleteThis");
if (curButton != null) {
curButton.Attributes.Add("onclick", "return confirm('Delete This?');");
}
}

-HTH

"Patrick.O.Ige" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?



 
Reply With Quote
 
 
 
 
Patrick Olurotimi Ige
Guest
Posts: n/a
 
      06-17-2005
Thx Jeremy but i fixed that earlier using ItemBound.
But i still have one more issue since the CheckBoxList is Databinded i
would like to get the selected item but when i looped through it isn't
returning it.What i mean is that want to get a Boolean value TRUE or
FALSE when the CheckBoxlist is selected.
Any trick for this





*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkboxlist inside Repeater - doesn't fire click event for Checkboxlist JD ASP .Net 5 08-08-2007 11:28 AM
Getting Databinded CheckBoxlist to display Boolean value ? Patrick.O.Ige ASP .Net 5 10-30-2006 08:17 PM
Looking for a CheckBoxList(DataBinded) in a DataList sample on the NET Patrick Olurotimi Ige ASP .Net 0 06-22-2005 03:04 AM
How to get Selected item in a Databinded CheckBoxList when CheckBoxlist is in a DataList? Patrick.O.Ige ASP .Net 5 06-19-2005 06:11 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM



Advertisments