I have created Checkbox list and Button to store Checked Values in ASP.Net application using C# as follows,
<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"/>
I have binded CheckBoxList in Code behind as,
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();
}
And the button click event to store the selected values in DataBase as follows,
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);
}
}
Now,i have another button to edit the CheckBoxList Selection.Now,i want to retrieve the data from database and check the checkboxes which are availabe(inserted checkbox values in databse when click save button) in DataBase when Clicking Edit Button.
Aucun commentaire:
Enregistrer un commentaire