Note that there are some explanatory texts on larger screens.

plurals
  1. PODetailView update is not working
    primarykey
    data
    text
    <p>I have googled every where but without a clear answer I am trying to update a record using Detail view using the following code:</p> <pre><code> &lt;asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="Rec_ID" DataSourceID="ContactsMasterDS" ForeColor="Black" GridLines="None" PageSize="3"&gt; &lt;AlternatingRowStyle BackColor="PaleGoldenrod" /&gt; &lt;Columns&gt; &lt;asp:CommandField ShowSelectButton="True" /&gt; &lt;asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /&gt; &lt;asp:BoundField DataField="Full_Name" HeaderText="Full_Name" SortExpression="Full_Name" /&gt; &lt;asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" /&gt; &lt;asp:BoundField DataField="AgeGroup" HeaderText="AgeGroup" SortExpression="AgeGroup" /&gt; &lt;asp:BoundField DataField="Nationality" HeaderText="Nationality" SortExpression="Nationality" /&gt; &lt;asp:BoundField DataField="Occupation" HeaderText="Occupation" SortExpression="Occupation" /&gt; &lt;asp:BoundField DataField="Resident" HeaderText="Resident" SortExpression="Resident" /&gt; &lt;/Columns&gt; &lt;FooterStyle BackColor="Tan" /&gt; &lt;HeaderStyle BackColor="Tan" Font-Bold="True" /&gt; &lt;PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" /&gt; &lt;SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" /&gt; &lt;SortedAscendingCellStyle BackColor="#FAFAE7" /&gt; &lt;SortedAscendingHeaderStyle BackColor="#DAC09E" /&gt; &lt;SortedDescendingCellStyle BackColor="#E1DB9C" /&gt; &lt;SortedDescendingHeaderStyle BackColor="#C2A47B" /&gt; &lt;/asp:GridView&gt; &lt;asp:SqlDataSource ID="ContactsMasterDS" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;" ProviderName="&lt;%$ ConnectionStrings:ConnectionString.ProviderName %&gt;" SelectCommand="Select * from Contacts"&gt;&lt;/asp:SqlDataSource&gt; &lt;br /&gt; &lt;asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Rec_ID" DataSourceID="ContactsDetailsDS" Height="50px" Width="545px" onitemupdated="DetailsView1_ItemUpdated"&gt; &lt;Fields&gt; &lt;asp:BoundField DataField="Rec_ID" HeaderText="Rec_ID" ReadOnly="True" SortExpression="Rec_ID" /&gt; &lt;asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" /&gt; &lt;asp:BoundField DataField="AgeGroup" HeaderText="AgeGroup" SortExpression="AgeGroup" /&gt; &lt;asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /&gt; &lt;asp:BoundField DataField="Full_Name" HeaderText="Full_Name" SortExpression="Full_Name" /&gt; &lt;asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" /&gt; &lt;asp:BoundField DataField="Phone_No" HeaderText="Phone_No" SortExpression="Phone_No" /&gt; &lt;asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" /&gt; &lt;asp:BoundField DataField="Nationality" HeaderText="Nationality" SortExpression="Nationality" /&gt; &lt;asp:BoundField DataField="Account_No" HeaderText="Account_No" SortExpression="Account_No" /&gt; &lt;asp:BoundField DataField="Occupation" HeaderText="Occupation" SortExpression="Occupation" /&gt; &lt;asp:BoundField DataField="Resident" HeaderText="Resident" SortExpression="Resident" /&gt; &lt;asp:BoundField DataField="Room_No" HeaderText="Room_No" SortExpression="Room_No" /&gt; &lt;asp:BoundField DataField="Last_Branch" HeaderText="Last_Branch" SortExpression="Last_Branch" /&gt; &lt;asp:BoundField DataField="Last_Date" HeaderText="Last_Date" SortExpression="Last_Date" /&gt; &lt;asp:BoundField DataField="Last_Time" HeaderText="Last_Time" SortExpression="Last_Time" /&gt; &lt;asp:CheckBoxField DataField="isComplete" HeaderText="isComplete" SortExpression="isComplete" /&gt; &lt;asp:CommandField ShowEditButton="True" /&gt; &lt;/Fields&gt; &lt;/asp:DetailsView&gt; &lt;asp:SqlDataSource ID="ContactsDetailsDS" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;" ProviderName="&lt;%$ ConnectionStrings:ConnectionString.ProviderName %&gt;" SelectCommand="Select * from Contacts where [Rec_ID] = @Rec_ID" UpdateCommand="Update Contacts Set Room_No=@Room_No Where Rec_ID=@Rec_ID" &gt; &lt;SelectParameters&gt; &lt;asp:ControlParameter ControlID="GridView1" Name="Rec_ID" PropertyName="SelectedValue" /&gt; &lt;/SelectParameters&gt; &lt;UpdateParameters&gt; &lt;asp:Parameter Name="Room_No" Type="String" /&gt; &lt;asp:Parameter Name="Rec_ID" Type="String" DefaultValue="0" /&gt; &lt;/UpdateParameters&gt; &lt;/asp:SqlDataSource&gt; </code></pre> <p>when I change the where clause to be "Where Rec_ID = 2" it works, but when using parameter it does not do the required update any help please </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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