https://www.17buddies.rocks/index.html

17's Buddies Maps HL1 Maps HL2 Wads Plan des Maps
17 Buddies
Only for stats

Welcome Guest ( Log In | Register )

[asp.net / C#], Probleme incomprehenssible
G!mL!
post 14/01/2005 - 17:37:42 |   Post #1
+Reply

Group: Member
Posts: 71
Joined: 31/12/2004

be 


J'ai un gros probleme en ASP/C#. Je ne comprend pas du tout ce que c'est.

J'ai mis un datagrid dans ma page avec un bouton Modifier et un Supprimer.

Quand je click sur le bouton modifier, le datagrid affiche des textbox dans la ligne selectionné. Je modifie la valeur et normalement en clickant sur le bouton "mise a jour" le programme est censé recupéré les text contenu dans la textbox et fais une update sur mon server SQL.

Seulement, il récupère l'ancien valeur avant modification.

Le code est :

CODE
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string id = this.DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
string Co1 = ((TextBox)e.Item.FindControl("TB_Cot1")).Text;
string Co2 = ((TextBox)e.Item.FindControl("TB_Cot2")).Text;
string Co3 = ((TextBox)e.Item.FindControl("TB_Cot3")).Text;
string Co4 = ((TextBox)e.Item.FindControl("TB_Cot4")).Text;
string UpdateQuery = "UPDATE Table_Excel SET Cot1 ='" + Co1 + "',Cot2 ='" + Co2 + "',Cot3 ='" + Co3 + "',Cot4 ='" + Co4 + "' WHERE Id_Eleve = '" + id + "'";
this.sqlCommand1.CommandText = UpdateQuery;
this.sqlCommand1.CommandType = CommandType.Text;
this.sqlCommand1.Connection = this.sqlConnection1;
this.sqlConnection1.Open();
int flag = this.sqlCommand1.ExecuteNonQuery();
this.sqlConnection1.Close();
if (flag !=1)
{
 this.Label1.Text = "Erreur lors de la mise a jour.";
}
else
{
 this.Label1.Text = "Modification effectuée correctement.";
 this.DataGrid1.EditItemIndex = -1;
 Chargement();
}

}


Donc si quelqu'un pouvait m'aidé, ce serait gentils !!!
Post PM
Go to the top of the page

Posts in this topic

2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

New
 


RSS Lo-Fi Version
 
Skin © Chapo