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" <Pa*********@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
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?