Bon bah c'est encore moi, pour la N-ième fois je viens me plaindre sur le forum, je commence a etre un habitué!
Cette fois ci je ne pense pas que ca seras un simple probleme d'espace,
alors merci d'avance a tout ceux qui vont me preter main forte

!
Mon probleme est que comme toujours j'ai recupérer le code fait par WebMatrix et j'l'ai adapter pour que ca fonctionne avec MySQL!
On a donc un Datagrid avec 2 colonne pour la gestion d'une base de donnée!
une colonne avec 'Modifier', une colonne avec 'Supprimer' (d'ailleur la suppression fonctionne tres bien

)
Lorsque l'on clic sur 'Modifier', la ligne de l'enregistrement concerné
apparait qu'avec des TextBox (pour pouvoir faire les modif') et le
'Modifier' se "transforme" en 'Valider Annuler' qui vous l'aurez
compris permettent de valider ou annuler la modification apportée!
Bon j'espere avoir été assez clair, maintenant mon probleme:
Tout mes TextBox apparaissent mais apres les avoir remplis et avoir
cliqué sur 'Valider' bah pouf y'a rien qui s'affiche, en fait je tape
pour rien et ca c'est pas plaisant vous en conviendrez

!
Alors bah je vous laisse mon code pour la fonction que je suppose foireuse:
void DataGrid_Update(object sender, DataGridCommandEventArgs e) {
// update the database with the new values
// get the edit text boxes
//string ID = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
string Nom = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
string Prenom = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
string Pass = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
// TODO: update the Command value for your application
OdbcConnection myConnection = new OdbcConnection(ConnectionString);
OdbcCommand UpdateCommand = new OdbcCommand();
UpdateCommand.Connection = myConnection;
if (AddingNew){
UpdateCommand.CommandText =
"INSERT INTO Login(Nom, Prenom, Pass) VALUES (@Nom, @Prenom, @Pass)";
}else{
UpdateCommand.CommandText =
"UPDATE Login SET Nom = @Nom, Prenom = @Prenom, Pass = @Pass WHERE ID =
@ID";
}
//UpdateCommand.Parameters.Add("@ID", OdbcType.VarChar, 11).Value = ID;
UpdateCommand.Parameters.Add("@Nom", OdbcType.Text, 40, "Nom"); //).Value = Nom;
UpdateCommand.Parameters.Add("@Prenom", OdbcType.Text, 20, "Prenom"); //).Value = Prenom;
UpdateCommand.Parameters.Add("@Pass", OdbcType.Text, 20, "Pass"); //).Value = Pass;
// execute the command
try {
myConnection.Open();
UpdateCommand.ExecuteNonQuery();
}
catch (Exception ex) {
Message.Text = ex.ToString();
}
finally {
myConnection.Close();
}
// Resort the grid for new records
if (AddingNew) {
DataGrid1.CurrentPageIndex = 0;
AddingNew = false;
}
// rebind the grid
DataGrid1.EditItemIndex = -1;
BindGrid();
}
Voilà sinon je peux vous énumérer les fonctions utilisé:
void Page_Load(object sender, EventArgs e)
void DataGrid_ItemCommand(object sender, DataGridCommandEventArgs e)
void CheckIsEditing(string commandName)
void DataGrid_Edit(object sender, DataGridCommandEventArgs e)
void DataGrid_Update(object sender, DataGridCommandEventArgs e)
void DataGrid_Cancel(object sender, DataGridCommandEventArgs e)
void DataGrid_Delete(object sender, DataGridCommandEventArgs e)
void DataGrid_Page(object sender, DataGridPageChangedEventArgs e)
void AddNew_Click(Object sender, EventArgs e)
protected bool AddingNew
void BindGrid()
Ah oui j'ai aussi un LinkButton pour ajouter un enregitrement (d'où le
AddNew) qui me pose aussi des probleme, mais chaque chose en sont
temps, je reviendrais dessus apres avoir reglé le pb de la modif'!
Merci a tous pour votre future aide!
Mets spiderman comme sonnerie de téléphone à ta
copine si tu trouve pas d'autre moyen pour la faire grimper au plafond
(Dixit SFR)