0
我有一個複選框列表,從數據庫中獲取其數據。用戶將選擇/複選框並單擊刪除。刪除後,我正在重新綁定新數據,但這些更改未反映出來。該頁面仍顯示那些選中的複選框。儘管DB中的記錄被刪除。我錯過了什麼。CheckBoxList未更新 - ASP.Net
ASPX:
<asp:CheckBoxList ID="cblLanguages" runat="server" AppendDataBoundItems="true"
DataTextField="LanguageName" DataValueField="PKLanguageId" >
</asp:CheckBoxList>
<asp:Button ID="btnDelete" runat="server" OnClick="btnDelete_Click" Text="Delete" />
C#:
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
BindData();
}
}
protected void btnDelete_Click(object sender, EventArgs e)
{
DeleteLanguages();
BindData();
}
private void BindData()
{
DataSet dsData = LanguagesDB.GetLanguages();
cblLanguages.DataSource = dsData.Tables[0];
cblLanguages.DataBind();
}
private void DeleteLanguages()
{
//code to delete selected values
}