Problème FormParameter

nounours21_6 Messages postés 255 Date d'inscription mercredi 3 novembre 2004 Statut Membre Dernière intervention 21 avril 2009 - 18 avril 2008 à 12:02
nounours21_6 Messages postés 255 Date d'inscription mercredi 3 novembre 2004 Statut Membre Dernière intervention 21 avril 2009 - 23 avril 2008 à 10:23
Bonjour,

Pour un site en ASP.NET 2.0, je dois gérer une liste de catégories. Pour cela j'utilise un Gridview avec une SqlDaraSource (modification/suppression/visualisation) et pour l'ajout, je voudrais ajouter par l'intermédiare d'une TextBox.
J'utilise alors la méthode Insert() de ma SDS. Et la, c'est le drame!


<script
runat="server">









private





void

InsertCategorie(


object

source,


EventArgs

e){



this

.sdsCategorie.Insert();}




</





script


>

[...]
<

span>Nouvelle cat‚gorie : </span>

<asp:TextBox
ID="txtNouvelleCategorie"
runat="server"></asp:TextBox>

<

asp:RequiredFieldValidatorID="rfvTxtNouvelleCategorie"Display="static"runat="server"ControlToValidate="txtNouvelleCategorie"

ErrorMessage="RequiredFieldValidator">/!\ Veuillez saisir un libell‚ /!\
</asp:RequiredFieldValidator>

<asp:Button
ID="cmdAjoutCategorie"
runat="server"
Text="Ajouter"
OnClick="InsertCategorie"
/>

[...]
<

asp:SqlDataSourceID="sdsCategorie"runat="server"ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

DeleteCommand="DELETE FROM [t_categorie] WHERE [id_categorie] = @id_categorie"

InsertCommand="INSERT INTO [t_categorie] ([libelle_c]) VALUES (@libelle_c)"
SelectCommand="SELECT [id_categorie], [libelle_c] FROM [t_categorie] ORDER BY [libelle_c], [id_categorie]"

UpdateCommand="UPDATE [t_categorie] SET [libelle_c] = @libelle_c WHERE [id_categorie] = @id_categorie">

[...]

<InsertParameters>

<asp:FormParameter
Name="libelle_c"
FormField="txtNouvelleCategorie"
Type="String"
/>

</InsertParameters>

</asp:SqlDataSource>

Mais j'ai ce message d'erreur lorsque je valide :
System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'libelle_c', table '[...]\EBUY.MDF.dbo.t_categorie'; column does not allow nulls. INSERT fails.The statement has been terminated.

Pourtant le champ est rempli!

Si quelqu'un peut m'aider^^

Bonne journée

Enjoy @+ et merci d'avance

1 réponse

nounours21_6 Messages postés 255 Date d'inscription mercredi 3 novembre 2004 Statut Membre Dernière intervention 21 avril 2009
23 avril 2008 à 10:23
up :)
0
Rejoignez-nous