473,387 Members | 1,789 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,387 software developers and data experts.

How to add DataBinded CheckBoxList in Datalist

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?
Nov 19 '05 #1
2 2082
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?

Nov 19 '05 #2
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 ***
Nov 19 '05 #3

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

Similar topics

0
by: plz | last post by:
Is it possible to bind a checkboxlist if this checkboxlist is in a datalist I cant find any tutorials, examples or so about this could somebody help me?
3
by: Ed West | last post by:
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>...
0
by: krzysiek | last post by:
yellow everybody, This what i did is below, however i'm getting error when Checkboxlist shows relation' columns. <asp:DataList id="pytania_list" runat="server" Width="100%" DataSource='<%#...
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...

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.