|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
Sujet : Formview : erreur lors d'un update [ WebForms / WebControl ] (hysteria31)
Informations & options pour cette discussion
mercredi 29 novembre 2006 à 11:46:02 |
Formview : erreur lors d'un update

hysteria31
|
Bonjour à tous,
mon problème est le suivant.
Je crée un Formview alimenter par un ObjectDataSource. Par défaut, le Formview est en mode modification.
Une DropDownList me permet de sélectionner l'enregistrement désiré.
Lorsque je veux "updater" mon enregistrement j'obtient l'erreur suivante : Citation: |
L'index se trouve en dehors des limites du tableau.
|
Je ne sais pas si cela peut vous aider mais voici la trace de la pile. Citation:
[IndexOutOfRangeException: L'index se trouve en dehors des limites du tableau.]
System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +446
[Exception: n'est pas une valeur valide pour Int32.]
System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +465
System.ComponentModel.TypeConverter.ConvertFromInvariantString(String text) +36
System.Web.UI.WebControls.ObjectDataSourceView.ConvertType(Object value, Type type, String paramName) +67
System.Web.UI.WebControls.ObjectDataSourceView.BuildObjectValue(Object value, Type destinationType, String paramName) +170
System.Web.UI.WebControls.ObjectDataSourceView.BuildDataObject(Type dataObjectType, IDictionary inputParameters) +207
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +1143
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary
values, IDictionary oldValues, DataSourceViewOperationCallback
callback) +78
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg, Boolean causesValidation) +1152
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +450
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +88
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +86
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +155
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +172
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4919
|
Enfin ci-dessous mon code source : Code : <form id="form1" runat="server"> Selectionnez une manifestation : <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="ObjectDataSource2" DataTextField="Name" DataValueField="Id"> </asp:DropDownList><asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="ListManifestations" TypeName="Util"> <SelectParameters> <asp:Parameter Name="id" Type="Int32" /> <asp:Parameter Name="name" Type="String" /> <asp:Parameter Name="dateBegin" Type="DateTime" /> <asp:Parameter Name="dateEnd" Type="DateTime" /> <asp:Parameter Name="nbPartWaited" Type="Int32" /> <asp:Parameter Name="comments" Type="String" /> <asp:Parameter Name="thmId" Type="Int32" /> <asp:Parameter Name="catId" Type="Int32" /> <asp:Parameter Name="placeId" Type="Int32" /> <asp:Parameter Name="srvcId" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> <br /> _____________________________________<br /> <br /> <br /> <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1" Height="103px" Width="336px" DefaultMode="Edit" CellPadding="4" DataKeyNames="Name,NbPartWaited,DateBegin,ThmId,DateEnd,Comments,SrvcId,PlaceId,CatId" ForeColor="#333333" PageIndex="1"> <ItemTemplate> CatId: <asp:Label ID="CatIdLabel" runat="server" Text='<%# Bind("CatId") %>'></asp:Label><br /> PlaceId: <asp:Label ID="PlaceIdLabel" runat="server" Text='<%# Bind("PlaceId") %>'></asp:Label><br /> SrvcId: <asp:Label ID="SrvcIdLabel" runat="server" Text='<%# Bind("SrvcId") %>'></asp:Label><br /> NbPartWaited: <asp:Label ID="NbPartWaitedLabel" runat="server" Text='<%# Bind("NbPartWaited") %>'> </asp:Label><br /> DateBegin: <asp:Label ID="DateBeginLabel" runat="server" Text='<%# Bind("DateBegin") %>'></asp:Label><br /> Id: <asp:Label ID="IdLabel" runat="server" Text='<%# Bind("Id") %>'></asp:Label><br /> ThmId: <asp:Label ID="ThmIdLabel" runat="server" Text='<%# Bind("ThmId") %>'></asp:Label><br /> Name: <asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>'></asp:Label><br /> DateEnd: <asp:Label ID="DateEndLabel" runat="server" Text='<%# Bind("DateEnd") %>'></asp:Label><br /> Comments: <asp:Label ID="CommentsLabel" runat="server" Text='<%# Bind("Comments") %>'></asp:Label><br /> <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Modifier"> </asp:LinkButton> <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="Nouveau"> </asp:LinkButton> </ItemTemplate> <EditItemTemplate> Name: <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' Width="311px"></asp:TextBox><br /> NbPartWaited: <asp:TextBox ID="NbPartWaitedTextBox" runat="server" Text='<%# Bind("NbPartWaited") %>'> </asp:TextBox><br /> DateBegin: <asp:TextBox ID="DateBeginTextBox" runat="server" Text='<%# Bind("DateBegin") %>'> </asp:TextBox> <br /> DateEnd: <asp:TextBox ID="DateEndTextBox" runat="server" Text='<%# Bind("DateEnd") %>'> </asp:TextBox><br />
<asp:TextBox ID="IdTextBox" runat="server" Text='<%# Bind("Id") %>' Visible="false"> </asp:TextBox>
<br /> Comments: <asp:TextBox ID="CommentsTextBox" runat="server" Text='<%# Bind("Comments") %>' Height="99px" TextMode="MultiLine" Width="284px"></asp:TextBox><br /> ThmId: <asp:TextBox ID="ThmIdTextBox" runat="server" Text='<%# Bind("ThmId") %>'> </asp:TextBox><br /> CatId: <asp:TextBox ID="CatIdTextBox" runat="server" Text='<%# Bind("CatId") %>'> </asp:TextBox><br /> PlaceId: <asp:TextBox ID="PlaceIdTextBox" runat="server" Text='<%# Bind("PlaceId") %>'> </asp:TextBox><br /> SrvcId: <asp:TextBox ID="SrvcIdTextBox" runat="server" Text='<%# Bind("SrvcId") %>'> </asp:TextBox><br /> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Mettre à jour"> </asp:LinkButton> <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Annuler"> </asp:LinkButton> </EditItemTemplate> <InsertItemTemplate> CatId: <asp:TextBox ID="CatIdTextBox" runat="server" Text='<%# Bind("CatId") %>'> </asp:TextBox><br /> PlaceId: <asp:TextBox ID="PlaceIdTextBox" runat="server" Text='<%# Bind("PlaceId") %>'> </asp:TextBox><br /> SrvcId: <asp:TextBox ID="SrvcIdTextBox" runat="server" Text='<%# Bind("SrvcId") %>'> </asp:TextBox><br /> NbPartWaited: <asp:TextBox ID="NbPartWaitedTextBox" runat="server" Text='<%# Bind("NbPartWaited") %>'> </asp:TextBox><br /> DateBegin: <asp:TextBox ID="DateBeginTextBox" runat="server" Text='<%# Bind("DateBegin") %>'> </asp:TextBox><br /> Id: <asp:TextBox ID="IdTextBox" runat="server" Text='<%# Bind("Id") %>'> </asp:TextBox><br /> ThmId: <asp:TextBox ID="ThmIdTextBox" runat="server" Text='<%# Bind("ThmId") %>'> </asp:TextBox><br /> Name: <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>'> </asp:TextBox><br /> DateEnd: <asp:TextBox ID="DateEndTextBox" runat="server" Text='<%# Bind("DateEnd") %>'> </asp:TextBox><br /> Comments: <asp:TextBox ID="CommentsTextBox" runat="server" Text='<%# Bind("Comments") %>'> </asp:TextBox><br /> <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insérer"> </asp:LinkButton> <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Annuler"> </asp:LinkButton> </InsertItemTemplate> <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#FFFBD6" ForeColor="#333333" /> <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /> <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> </asp:FormView> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" InsertMethod="InsertManifestation" SelectMethod="ListManifestations" TypeName="Util" UpdateMethod="UpdateManifestation" DataObjectTypeName="Pape02.Common.Manifestation"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="id" PropertyName="SelectedValue" Type="Int32" /> <asp:Parameter Name="name" Type="String" /> <asp:Parameter Name="dateBegin" Type="DateTime" /> <asp:Parameter Name="dateEnd" Type="DateTime" /> <asp:Parameter Name="nbPartWaited" Type="Int32" /> <asp:Parameter Name="comments" Type="String" /> <asp:Parameter Name="thmId" Type="Int32" /> <asp:Parameter Name="catId" Type="Int32" /> <asp:Parameter Name="placeId" Type="Int32" /> <asp:Parameter Name="srvcId" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource>
</form>
Je vous remercie d'avance pour votre aide.
Damien
|
|
|
mercredi 29 novembre 2006 à 13:42:24 |
Re : Formview : erreur lors d'un update

bernie666
|
Salut, c'est normal que tu es une erreur sur l'upade :) je te rassure c'est pas de ta faute ;) c'est juste un petit bug dans le generateur de code de visual studio => en fait il y a un petit probleme sur la requete update => il faut que tu modifie le nom de tes parametres pour qu'il correspondent avec les variable des composants dans ta formview en mode update ;)
voila voila :)
++
|
|
|
mercredi 29 novembre 2006 à 14:13:01 |
Re : Formview : erreur lors d'un update

hysteria31
|
Salut Bernie, merci de ta réponse. J'ai changé les noms pour qu'il soit identique mais j'ai toujours la même erreur. Peux-tu préciser ta réponse pour que je vérifie si j'ai bien ce qu'il fallait ? En fait moi, j'ai enlevé la majuscule ci-dessous : <asp:TextBox ID="DateEndTextBox" runat="server" Text='<%# Bind("DateEnd") %>'> </asp:TextBox><br />
pour que ce soit identique à ça :
<asp:Parameter Name="dateEnd" Type="DateTime" />
Merci encore.
|
|
|
mercredi 29 novembre 2006 à 14:42:36 |
Re : Formview : erreur lors d'un update

bernie666
|
Réponse acceptée !
euh tu a bien regarder dans la requete parametrée générée si les nom des parametres correspondant bien ?
Moi perso avec ce bug maintenant je me prend pu la tete, je genere insert, delete , select et l update je le fait a la mimine
++
|
|
|
mercredi 29 novembre 2006 à 15:10:09 |
Re : Formview : erreur lors d'un update

hysteria31
|
Merci Bernie,
j'ai trouvé la solution. En fait ma fonction update avait pour paramètre un objet et non la liste de ces paramètres. Avec la 2ème solution, c'est ok.
Dans l'absolue, j'aimerai trouvé une solution me permettant de passer un objet directement mais pour l'instant je me contenterai de ça.
Merci pour tes réponses en tout cas.
A bientôt
Damien
|
|
|
mercredi 29 novembre 2006 à 15:24:40 |
Re : Formview : erreur lors d'un update

bernie666
|
No problem
Bonne continuation
++
Par contre si un jour tu tombe sur une info (patch ou autre qui permet de corriger ce bug sa m'interesse ;)... j'ai pas cherché pendant 10 ans non plus mais j'ai jamais rien trouvé ...)
|
|
|
Cette discussion est classé dans : web, system, ui, object, webcontrols
Répondre à ce message
Sujets en rapport avec ce message
Objet non instancié??? [ par gpirson ]
Bonjour, c'est la première fois que je viens sur ce forum alors je ne suis pas vraiment au courant du protocole.J'ai un petit problème, est ce que que
Programmation sous Word [ par marik7335 ]
Bonjour, Je suis confronté à un problème depuis quelques temps. Je souhaite générer des rapports au format Doc (avec Word). Pour celà je dispose d
Impression d'un System.Web.UI.Webcontrols.Table [ par fdecandido ]
Bonjour,Je suis debutant en .net et developpe en c#.Je dois faire un moteur de resa hotel en ligne.L'utilisateur saisie un certain nombre de param cho
besoin d'éclaircissements sur le traçage d'une exception [ par equinoxe83 ]
Bonjour à tous,Pas sur que j'ai posté dansle bon thème ... Merci de m'indiquer si je dois le ré-aiguiller.Bref, mon Pb est le suivant :J'ai un formvie
Textbox créé dynamiquement [ par zoum2000 ]
Bad Brown Fox speaking.Bonjour à tous,J'ai généré des textboxs dynamiques (id inclus) en fonction du nombre de ligne retournée par ma requête SQL que
Server == null ! [ par darunia ]
Salut,Je suis en train de faire une appli a l'aide des UserControl.Malheureusement, lors de l'execution, l'appli plante lamentablement :
Fonction UPDATE sur une base Access [ par vince2472 ]
Bonjour,Je rencontre un pb : j'ai le message 'Erreur de syntaxe dans l'instruction UPDATE' lorsque je mets ma base à jour (le but étant de la modifier
NullReferenceException: Object reference not set to an instance of an object... [ par aeterna ]
Bonjoir ^^,Quelqu'un pourrait-il me dire où ça cloche ? Je suis vraiment noob donc le moindre petitindice serait le bienvenu ;)L'erreur suivante se pr
[asp][xsl] erreur incompréhensible [ par keliante ]
bonjour à tous, dans ma page j'ai réalisé une transformation avec un xml et un xsl.Je n'avait jamais eu de problème mais ce matin avec des nouveaux x
pb DataNavigateUrlField [ par nounours21_6 ]
bonjour,j'ai créer un datagrid, avec une colonne de lien hypertexteet je voudrai faire comma dans la source :http://www.aspfr.com/forum.v2.aspx?ID=584
Livres en rapport
|
Téléchargements
Logiciels à télécharger sur le même thème :
|