Problème récupération des données d'un textbox dans datagrid
Bonjour!
J'ai plein de datagrid qui fonctionnent bien dans mon application web, mais voilà que j'ai un problème avec un seul!!
J'ai un seul textbox dedans en plus, lorsque je met à jour je veux récupérer sa valeur, mais au lieu de récupérer la valeur actuelle du textbox, ca va récupérer la valeur qui a dans la base de données, c'est à dire la valeur du champ avant même que je fasse des changements. Il doit y avoir un problème innocent quelque part!
Voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
<asp:datagrid id="EtatCommande" runat="server" Width="1040px"
CellPadding="4" BackColor="White" BorderWidth="1px"
BorderStyle="None" BorderColor="#CC9966" AutoGenerateColumns="False" OnEditCommand="EtatCommande_Edit"
OnCancelCommand="EtatCommande_Cancel" OnUpdateCommand="EtatCommande_Update"
OnDeleteCommand="EtatCommande_DeleteCommand" OnItemCreated="EtatCommande_ItemCreated">
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
<AlternatingItemStyle BackColor="Moccasin"></AlternatingItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></HeaderStyle>
<Columns>
<asp:BoundColumn Visible="False" DataField="idProduit" HeaderText="idProduit" ReadOnly="True"></asp:BoundColumn>
<asp:BoundColumn DataField="dateProduit" HeaderText="Date" ReadOnly=true DataFormatString="{0:dd MMM yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="nomProduit" HeaderText="Nom produit"></asp:BoundColumn>
<asp:BoundColumn DataField="nomComplet" HeaderText="Employé" ReadOnly=true></asp:BoundColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Sauvegarder" CancelText="Annuler" EditText="[Modifier]"></asp:EditCommandColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton id="delete" runat="server" CommandName="Delete" Text="[Supprimer]"/>
<ajax:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="delete"
ConfirmText="Êtes-vous sûr de vouloir supprimer cette commande?"
/>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
public void EtatCommande_Update(object source, DataGridCommandEventArgs e)
{
string idProduit, nomProduit;
FbCommand myCommand;
string connStr = ConfigurationManager.AppSettings["connectionString"];
FbConnection myConnection = new FbConnection(connStr);
nomProduit = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
idProduit = e.Item.Cells[0].Text;
myCommand = new FbCommand("UPDATE_COMMANDEPRODUITS", myConnection);
myCommand.CommandType = System.Data.CommandType.StoredProcedure;
myCommand.Parameters.Add("@idProduit", FbDbType.Integer).Value = idProduit;
myCommand.Parameters.Add("@nomProduit", FbDbType.VarChar).Value = nomProduit;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
EtatCommande.EditItemIndex = -1;
}
catch (Exception ex)
{
Response.Write("<br><br><b>Message:</b><br><br>" + ex.Message);
Response.Write("<br><br><b>Description:</b><br><br>" + ex.ToString());
}
finally
{
myConnection.Close();
}
AfficherCommande();
} |
Merci pour toute aide apporté à mon problème :)
Mona