Hello. i Am using Visual Studio 2003 .NET and C#. i have a timesheet database. in there are 2 tables: employees and timeattendance. these 2 tables have a common column: employeeID.
On the add employee screen, an employee is added and a new row is created in the employees tabele filled with required fields.similarly, a new row is automatically added to the timeattendance table whenever a new employee is added. the new row in the timeattendance table has the employeeid field filled.
Adding is working perfectly in both tables.
the problem is when deleteing; the row is being deleted from the employees table only and not from the timeattendance table.
Compilation is error-free and no run-time errors exist.Here's the code:
protected void OnItemClicked(object source, DataGridCommandEventArgs e)
//Get the index of the item that was selected
int itemindex = (int)e.Item.ItemIndex;
if (e.CommandName == "Select")
//Save the index of the selected item in the view state
ViewState["SelectedItemIndex"] = itemindex;
//Fill the edit boxes with the selected employees name
DataRow selectedRow = ds.Tables["Employees"].Rows[itemindex];
txtNameEdit.Text = selectedRow["Name"].ToString();
txtEmployeeIDUpdate.Text = selectedRow["EmployeeID"].ToString();
//Enable the edit controls
txtNameEdit.Enabled = true;
txtEmployeeIDUpdate.Enabled = true;
btnEmployeeUpdate.Enabled = true;
DataRow drs= ds.Tables["Employees"].Rows[itemindex];
string dc =drs["EmployeeId"].ToString();
DataRow drc= ds2.Tables["TimeAttendance"].Select("EmployeeId = " + dc);
//Delete the selected employee, delete works fine here
===========>>>>//Something is not workoing in this line
//Update the database
//Update the session DataSet
Session["ds"] = ds;
Session["ds2"] = ds2;