read check box control's value in datalist
-
i have data list which has check box in item template. i bound this data list to data source through coding. but when i try to read check box values which are checked i donot get any value though check box is checked. my code is like protected void Button1_Click(object sender, EventArgs e) { foreach (DataListItem _obj in dlAddressType.Items) { if (_obj.ItemIndex > -1) { Label _lbl = (Label)_obj.FindControl("lblAddressTypeID"); int chkID; string chkVal; chkVal = _lbl.Text; chkID = Convert.ToInt32(chkVal); CheckBox _checkBox = (CheckBox)_obj.FindControl("chkAddressType"); if (flag != 1) { if (_checkBox.Checked == true) { _ag.AddAddress(ad); // now the addressGroup object has 2 addresses in it. // indicate this is the shipping address AddressTypeID = 5 _ag._AddressDetails[chkID].AddressClientSideID = ad.ClientSideID; } } else { if (_checkBox.Checked == true) { _ag = new AddressGroup(ad); _ag._AddressDetails[chkID].AddressClientSideID = ad.ClientSideID; flag = 0; } } } } }