I have 2 listboxes. One contains all the department which are unassigned and other listbox contains all the department which is assigned to a particular person. Now I want to add and delete departments using insert and delete query. The query will be performed on 1 table only ie Assigned Department(listbox2) and by clicking the SAVE button. I have done the insert part but unable to handle the delete part. I have seen few examples but they dont have DB event in them.
protected void Save_Click(object sender, EventArgs e)
{
DataTable dt = GetData2();
bool found = false;
foreach (RadListBoxItem item in RadListBox2.Items)
{
found = false;
foreach (DataRow dr in dt.Rows)
{
if (String.Compare(item.Value, dr["DeptID"].ToString()) == 0)
{
found = true;
label1.Text = "Add a New Group to the ListBox";
}
}
if (found == false)
{
Item(item.Text, item.Value);
}
This is what I am trying to do. I want to handle insert and delete event on Save button.
I figured out the solution so I am posting it in here.