Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7969209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:12:02+00:00 2026-06-04T07:12:02+00:00

I have a gridview that is filled correctly from 3 tables. When I update

  • 0

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.

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID,Erledigt,Kommentar"
        DataSourceID="ArtikelDataSource">
        <Columns>
            <asp:CommandField ShowEditButton="True" />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" 
                ReadOnly="True"  >
            <ControlStyle Width="150px" />
            </asp:BoundField>
            <asp:BoundField DataField="Beschreibung" HeaderText="Beschreibung" 
                SortExpression="Beschreibung" ReadOnly="True" >
            <ControlStyle Width="200px" />
            </asp:BoundField>
            <asp:BoundField DataField="Datum" HeaderText="Datum" SortExpression="Datum" 
                ReadOnly="True" >
            <ControlStyle Width="100px" />
            </asp:BoundField>
            <asp:BoundField DataField="Erledigt" HeaderText="Erledigt" 
                SortExpression="Erledigt" >
            <ControlStyle Width="50px" />
            </asp:BoundField>
            <asp:BoundField DataField="Kommentar" HeaderText="Kommentar" 
                SortExpression="Kommentar" >
            <ControlStyle Width="200px" />
            </asp:BoundField>
            <asp:BoundField DataField="LastUpdate" HeaderText="LastUpdate" 
                SortExpression="LastUpdate" ReadOnly="True" />
            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                ReadOnly="True" SortExpression="ID" Visible="False" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="ArtikelDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" 
        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"
        >
        <SelectParameters>
            <asp:Parameter Name="userlogin"/>
            <asp:Parameter Name="datum"/>
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Kommentar" Type="string"/>
            <asp:Parameter Name="ID" />
        </UpdateParameters>
    </asp:SqlDataSource>

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.

When I try to change the value of “Erledigt” via SQL

UpdateCommand="UPDATE ChecklistActions SET Erledigt = @Erledigt, Kommentar = @Kommentar, LastUpdate = GETDATE() WHERE (ID = @ID)" 
...
<asp:Parameter Name="Erledigt" Type="Int32"/>

nothing (except the Getdate()) is updated at all – not even the field Kommentar at the fist time

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:12:03+00:00Added an answer on June 4, 2026 at 7:12 am

    you missed , in your UpdateCommand

    UPDATE ChecklistActions SET Erledigt = @Erledigt, Kommentar = @Kommentar, LastUpdate = GETDATE() WHERE (ID = @ID)"
    

    edit

    Set only the primary key column names on your database tables as DataKeyNames, in this case you only update ChecklistActions table. so set primary key of ChecklistActions as DataKeyNames

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView in ASP.net which is filled from an SqlDataSource. one of
I have a gridview that shows an image as part of one of its
I have a gridview that displays items details, I added two template fields one
I have a gridview that is only shown in a modal popup. right before
I have a gridview that is bound to a datasource (Windows Forms, VB.NET). One
I have a gridview that contains user info and one of the columns is
I have a gridview that contains value of every rows read from a text
Basically, I have a gridview that is opened in a new window from the
I have two DropDownLists that are in a GridView. The DropDownLists only show when
I have GridView that allows select. It takes data from EntityDataSource . How do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.