Note that there are some explanatory texts on larger screens.

plurals
  1. POGridview not updating all fields
    text
    copied!<p>I have a gridview that is filled correctly from 3 tables. When I update it, it will only update one field (Kommentar) but only the first time.</p> <pre><code> &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID,Erledigt,Kommentar" DataSourceID="ArtikelDataSource"&gt; &lt;Columns&gt; &lt;asp:CommandField ShowEditButton="True" /&gt; &lt;asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" ReadOnly="True" &gt; &lt;ControlStyle Width="150px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="Beschreibung" HeaderText="Beschreibung" SortExpression="Beschreibung" ReadOnly="True" &gt; &lt;ControlStyle Width="200px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="Datum" HeaderText="Datum" SortExpression="Datum" ReadOnly="True" &gt; &lt;ControlStyle Width="100px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="Erledigt" HeaderText="Erledigt" SortExpression="Erledigt" &gt; &lt;ControlStyle Width="50px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="Kommentar" HeaderText="Kommentar" SortExpression="Kommentar" &gt; &lt;ControlStyle Width="200px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="LastUpdate" HeaderText="LastUpdate" SortExpression="LastUpdate" ReadOnly="True" /&gt; &lt;asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" Visible="False" /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;asp:SqlDataSource ID="ArtikelDataSource" runat="server" ConnectionString="&lt;%$ ConnectionStrings:MyConnectionString %&gt;" SelectCommand="SELECT ci.Name, ci.Beschreibung, ca.ChkItemID, ca.ChkUserID, ca.Datum, ca.Erledigt, ca.Kommentar, ca.LastUpdate, ca.ID FROM ChecklistActions AS ca INNER JOIN ChecklistItems AS ci ON ca.ChkItemID = ci.ID INNER JOIN ChecklistUsers AS cu ON ca.ChkUserID = cu.ID WHERE (ca.Datum = @datum) AND (cu.Login = @userlogin)" UpdateCommand="UPDATE ChecklistActions SET Kommentar = @Kommentar, LastUpdate = GETDATE() WHERE (ID = @ID)" OnSelecting="_data_Selecting" &gt; &lt;SelectParameters&gt; &lt;asp:Parameter Name="userlogin"/&gt; &lt;asp:Parameter Name="datum"/&gt; &lt;/SelectParameters&gt; &lt;UpdateParameters&gt; &lt;asp:Parameter Name="Kommentar" Type="string"/&gt; &lt;asp:Parameter Name="ID" /&gt; &lt;/UpdateParameters&gt; &lt;/asp:SqlDataSource&gt; </code></pre> <p>I have first an empty field "Kommentar", then it is filled, but when I try to change the value again, only the GETDATE() changes value, the content of Kommentar is the same as before.</p> <p>When I try to change the value of "Erledigt" via SQL</p> <pre><code>UpdateCommand="UPDATE ChecklistActions SET Erledigt = @Erledigt, Kommentar = @Kommentar, LastUpdate = GETDATE() WHERE (ID = @ID)" ... &lt;asp:Parameter Name="Erledigt" Type="Int32"/&gt; </code></pre> <p>nothing (except the Getdate()) is updated at all - not even the field Kommentar at the fist time</p> <p>It seems that the gridview is sending the old values to the update command (only the first update will receive the new Kommentar-value) which is really irritating ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload