locked
Help~~ My GridView record cannot update..... what's wrong... no error appear... RRS feed

  • Question

  • User618531804 posted

    The following code is my GridView and Access Data Source...

    when I click the edit button, it become a update and cancel link....

    when I click the update link the system process it and did'nt appear any error.. but my record did'nt update.......


    if I take away the   <asp:Parameter Name="LineNo" Type="String" /> the record will update... I need this column to specified my WHERE in sql query...

     

     

    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/Location/CAR.mdb"
                            SelectCommand="SELECT * FROM CarProblemDescription ORDER BY LineNo ASC"
                            UpdateCommand="UPDATE CarProblemDescription SET Description=@Description, ResponsibleBy=@ResponsibleBy WHERE CarNo=@CarNo AND LineNo=@LineNo">  
                    <UpdateParameters>
                        <asp:Parameter Name="Description" Type="String" />
                        <asp:Parameter Name="ResponsibleBy" Type="String" />
                        <asp:Parameter Name="CarNo" Type="String" />
                        <asp:Parameter Name="LineNo" Type="String" />
                    </UpdateParameters>
                        </asp:AccessDataSource>

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" GridLines="Vertical" EnableTheming="True" DataSourceID="AccessDataSource1">
                            <Columns>
                                <asp:BoundField DataField="LineNo" HeaderText="No." ReadOnly="true"  />
                                <asp:BoundField DataField="CarNo" HeaderText="Car No" Visible="False" HeaderStyle-HorizontalAlign="Left" />
                              
                                <asp:TemplateField HeaderText="Description" HeaderStyle-HorizontalAlign="Left">
                                    <ItemTemplate>
                                        <asp:TextBox Text='<%# Bind("Description") %>' runat="server" id="txtDescription" TextMode="MultiLine" Width="450px" Height="50px" Enabled="false" />
                                    </ItemTemplate>
                                   
                                    <EditItemTemplate>
                                        <asp:TextBox Text='<%# Bind("Description") %>' runat="server" id="txtDescription" TextMode="MultiLine" Width="450px" Height="50px" Enabled="true"  />
                                    </EditItemTemplate>
                                </asp:TemplateField>
               
                          <asp:TemplateField HeaderText="Description" HeaderStyle-HorizontalAlign="Left">
                                    <ItemTemplate>
                                        <asp:TextBox Text='<%# Bind("ResponsibleBy") %>' runat="server" id="txtDescription2" Enabled="false" />
                                    </ItemTemplate>
                                   
                                    <EditItemTemplate>
                                        <asp:TextBox Text='<%# Bind("ResponsibleBy") %>' runat="server" id="txtDescription2" Enabled="true"  /> 
                                    </EditItemTemplate>
                                </asp:TemplateField>
                               

                                <asp:CommandField ShowEditButton="True" ButtonType="Button" SelectText="Update"   />  
                            </Columns>
                        </asp:GridView>

    Thursday, August 14, 2008 9:58 AM

Answers

  • User-1995538749 posted

    Try setting the following property on your GridView:

    DataKeyNames="LineNo"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 14, 2008 2:33 PM
  • User-298277035 posted

    Is the primary key defined on  your table ?. Then only update will work.. if primary key is defined  put datakeynames="Your pimary key"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 14, 2008 2:38 PM
  • User618531804 posted

    Ooo!! I solved it already..

    because my GridView DataKeyNames do not contain my database neccessary column to identified my update parameter... I suppose apply as DataKeyNames="CarNo,LineNo"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 15, 2008 10:19 AM

All replies

  • User-1995538749 posted

    Try setting the following property on your GridView:

    DataKeyNames="LineNo"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 14, 2008 2:33 PM
  • User-298277035 posted

    Is the primary key defined on  your table ?. Then only update will work.. if primary key is defined  put datakeynames="Your pimary key"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 14, 2008 2:38 PM
  • User618531804 posted

    Ooo!! I solved it already..

    because my GridView DataKeyNames do not contain my database neccessary column to identified my update parameter... I suppose apply as DataKeyNames="CarNo,LineNo"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 15, 2008 10:19 AM
  • User1430456900 posted

    Hi !

     I've the same  issue as you but I cannot fix it :(  

    Why when I click on the update linkButton nothing happends and when I ckick on cancel, edit, delete everything is working ?

    1    <asp:GridView ID="MembreGridView" runat="server" AllowPaging="True" 
    2                                AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="UserId" 
    3                                DataSourceID="MembreLinqDataSource" CellPadding="4" ForeColor="#333333" 
    4                                GridLines="None">
    5                            
    6                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    7                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    8                            
    9                                <Columns>
    10                                   <asp:BoundField DataField="UserId" HeaderText="UserId" ReadOnly="True" 
    11                                       SortExpression="UserId" />
    12                                   <asp:BoundField DataField="Role" HeaderText="Role" SortExpression="Role" />
    13                                   <asp:BoundField DataField="Password" HeaderText="Password" 
    14                                       SortExpression="Password" />
    15                                   <asp:BoundField DataField="Civilite" HeaderText="Civilite" 
    16                                       SortExpression="Civilite" />
    17                                   <asp:BoundField DataField="Prenom" HeaderText="Prenom" 
    18                                       SortExpression="Prenom" />
    19                                   <asp:BoundField DataField="Nom" HeaderText="Nom" SortExpression="Nom" />
    20                                   <asp:BoundField DataField="Pays" HeaderText="Pays" 
    21                                       SortExpression="Pays" />
    22                                   <asp:BoundField DataField="Telephone" HeaderText="Telephone" 
    23                                       SortExpression="Telephone" />
    24                                   <asp:CheckBoxField DataField="DipScpo" HeaderText="DipScpo" 
    25                                       SortExpression="DipScpo" />
    26                                   <asp:BoundField DataField="AnneeDip" HeaderText="AnneeDip" 
    27                                       SortExpression="AnneeDip" />
    28                                   <asp:BoundField DataField="AnneePromo" HeaderText="AnneePromo" 
    29                                       SortExpression="AnneePromo" />
    30                                   <asp:BoundField DataField="Activite" HeaderText="Activite" 
    31                                       SortExpression="Activite" />
    32                                   <asp:BoundField DataField="Poste" HeaderText="Poste" SortExpression="Poste" />
    33                                   <asp:BoundField DataField="URLPhoto" HeaderText="URLPhoto" 
    34                                       SortExpression="URLPhoto" />
    35                                   <asp:BoundField DataField="URLCv" HeaderText="URLCv" SortExpression="URLCv" />
    36                                   <asp:BoundField DataField="LastActivityDate" HeaderText="LastActivityDate" 
    37                                       SortExpression="LastActivityDate" />
    38                                   <asp:CheckBoxField DataField="IsActivated" HeaderText="IsActivated" 
    39                                       SortExpression="IsActivated" />
    40                               </Columns>
    41                               
    42                               <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
    43                               <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    44                               <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    45                               <EditRowStyle BackColor="#999999" />
    46                               <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    47                               
    48                           </asp:GridView>
    49                           
    50                           <asp:LinqDataSource ID="MembreLinqDataSource" runat="server" 
    51                               ContextTypeName="DataClassesDataContext" EnableDelete="True" 
    52                               EnableUpdate="True" OrderBy="Nom, Prenom" TableName="Users">
    53                           </asp:LinqDataSource>
    

     

    Thx -)

    Wednesday, October 22, 2008 7:10 AM