我的aspx頁面我正在使用checkboxlist控件並從數據庫填充數據。但是,當我用來選擇項目和調試我的代碼總是選定的屬性用來作爲false.How解決這個問題。
我的代碼是如何獲得checkboxlist選定的屬性爲真
<asp:CheckBoxList ID="chkProduct" Width="200px" Height="90px" runat="server"
RepeatDirection="Vertical" style="overflow-y: scroll;
overflow-x: scroll;">
</asp:CheckBoxList>
代碼隱藏
for (int j = 0; j < chkProduct.Items.Count; j++)
{
//CheckBoxList chkProduct;
foreach (ListItem list in chkProduct.Items)
{
if (list.Selected)
{
enquiryProducts = new Services.EnquiryProduct();
enquiryProducts.IsDelete = false;
enquiryProducts.ProductID = Convert.ToInt32(chkProduct.Items[j].Value);
enquiryProductList.Add(enquiryProducts);
}
}
}
請把綁定代碼ASLO 。您可能會在頁面加載中綁定一個區域。 –
請檢查您的頁面posback事件,當您綁定checkboxlist – user1102001