Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete a record and display next or previous row
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Web forms
Title:
Delete a record and display next or previous row
Environment versions
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00961845
Message ID:
00961845
Views:
30
I am using this Function in my Data Class to delete a record:
public static void DeleteUser(string UserID)
		{
			SqlConnection DeleteUserConnection = GetConnection();
			string DeleteStatement	= "DELETE FROM UserInfo "
									+ "WHERE UserID=@UserID";

			SqlCommand DeleteCommand = new SqlCommand(DeleteStatement, DeleteUserConnection);
			DeleteCommand.Parameters.Add("@UserID", UserID);
			DeleteUserConnection.Open();
			DeleteCommand.ExecuteNonQuery();
			DeleteUserConnection.Close();

		}
When it fires it deletes the record as expected but then returns to the BOF or top of the file. Is it possible or desirable to change this behavior? After Deleting a record I would like to then display either the next or last record depending upon my choice and if it is BOF or EOF.

To repopulate the form I use:
private void BindForm()
		{
			string UserID;
			UserID = ddlUsers.SelectedItem.Value;

			DisplayUser = ScrapDB.GetUser(ddlUsers.SelectedValue.ToString());

			txtUserID.Text = DisplayUser.UserID;
			txtFirstName.Text = DisplayUser.FirstName;
			txtLastName.Text = DisplayUser.LastName;
			txtPhoneExtension.Text = DisplayUser.PhoneExt;
			
			dgUsers.DataSource = ScrapDB.FindUser(UserID);
			dgUsers.DataBind();
			
			ddlGroups.SelectedIndex =  ddlGroups.Items.IndexOf(ddlGroups.Items.FindByValue(DisplayUser.PositionName));
			ddlDepartments.SelectedIndex =  ddlDepartments.Items.IndexOf(ddlDepartments.Items.FindByValue(DisplayUser.DepartmentCode));

		}
Next
Reply
Map
View

Click here to load this message in the networking platform