1
我已經創建複選框列表和按鈕保存使用C#如下ASP.Net應用程序檢查的值的數據庫值如何檢查複選框,基於C#中
<asp:CheckBoxList ID="CheckBoxList1" runat="server" Width="120px">
</asp:CheckBoxList>
<asp:Button ID="AddCheckedData" Height="25px" runat="server" Text="Add Checked Data"
onclick="AddCheckedData_Click"/>
我已經在代碼綁定CheckBoxList的背後,
public void bindchecklist()
{
B.SFS_CODE = Convert.ToInt32(TxtHQCode.Text);
B.id = 7; //tblparent AND tblchild
ds8 = A.DATA8(B);
CheckBoxList1.DataSource = ds8.Tables[0];
CheckBoxList1.DataTextField = "EMP_NAME";
CheckBoxList1.DataValueField = "EMP_CODE";
CheckBoxList1.DataBind();
}
而到了選擇的值存儲在數據庫中按照下面的按鈕點擊事件,
string selemployee = string.Empty;
foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
selemployee = item.Value;
B.id = 8;//insert into DCR_CHECKED
B.Emp_Code = selemployee;
ds8 = A.DATA8(B);
}
}
現在,我有另一個按鈕來編輯CheckBoxList Selection.Now,我想從數據庫中檢索數據並在DataBase中單擊編輯按鈕時檢查可用的複選框(在單擊保存按鈕時在數據庫中插入複選框值)。
感謝您reply.i發現自己的答案與你的答覆的幫助。 – Ram