Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Delete a record and display next or previous row
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires Web
Titre:
Delete a record and display next or previous row
Versions des environnements
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
00961845
Message ID:
00961845
Vues:
31
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));

		}
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform