Hoe to get DataList Checkbox status in item template

V

Vannela

I want to get the status of the checkbox control in the
item template of the DataList in the code behind

Using findcontrol i am not able to get the status of the
checkbox . How shouls i get the status of the checkbox
whether it is checked or not?\

Thank you
 
E

Eugene Jenihov

Hi...

foreach(DataListItem item in MyDataList.Items) {
CheckBox myCheckBox = (CheckBox)item.FindControl("chkMyCheckBox");
if (myCheckBox.Checked)
{
//do some work
}
}
 
E

Eugene Jenihov

Domething like this...

Dim item As DataListItem
Dim myCheckBox As CheckBox
For Each item In DataList1.Items
If (CType(item.FindControl("chkMyCheckBox"),
CheckBox).Checked)
'Do some work
End If
Next item
 
V

Vannela

Hi

I am getting the error as null object reference
I am no able to get the checkbox of the datalist into the
my checkbox ie., myCheckBox

What could be the problem?


Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top