I have aspx web page with a GridView that displays data from a SqlDataSource
view that combines 2 tables to show information. It has an Edit feature and
the SqlDataSource has an UpdateCommand text to run a stored proc that has 2
UPDATE statements (1 for each table) as shown below. When I click the
Update link button in Edit mode, the 2nd table changes but not the 1st
table. I have tested the stored proc manually and both tables update fine.
Can someone help with this? Thanks.
David
<asp:SqlDataSource ID="SqlvwPeoplePropLink" runat="server"
ConnectionString="<%$ ConnectionStrings:RFPDataConnectionString %>"
DeleteCommand="DELETE FROM [PeoplePropLink] WHERE [PropLinkID] =
@PropLinkID"
SelectCommand="SELECT [PropLinkID], [PersonID], [RoleID], [RoleName],
[ContactName], [Phone], [CellPhone], [EmailLink], [Email], [PropertyRole],
[LinkNotes], [PrimaryPerson] FROM [vw_PeoplePropLink] WHERE [PropertyID] =
@QSPropID"
UpdateCommand="EXEC rfp_updPeopleAndLink @Phone, @CellPhone, @Email,
@PersonID, @LinkNotes, @PrimaryPerson, @PropLinkID">
<DeleteParameters>
<asp:Parameter Name="PropLinkID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="PersonID" Type="Int32" />
<asp:Parameter Name="RoleID" Type="Int32" />
<asp:Parameter Name="RoleName" Type="String" />
<asp:Parameter Name="PropLinkID" Type="Int32" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="CellPhone" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="LinkNotes" Type="String" />
<asp:Parameter Name="PrimaryPerson" Type="Boolean" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="PersonID" Type="Int32" />
<asp:Parameter Name="RoleID" Type="Int32" />
<asp:Parameter Name="RoleName" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:QueryStringParameter Name="QSPropID" QueryStringField="p" Type="Int32"
/>
</SelectParameters>
</asp:SqlDataSource>
David C - 24 Aug 2007 19:03 GMT
Found the answer. The GridView only had DatakeyNames for the 2nd table.
Once I added key for 1st table the update worked. Not sure why...maybe
someone can explain.
David
>I have aspx web page with a GridView that displays data from a
>SqlDataSource view that combines 2 tables to show information. It has an
[quoted text clipped - 67 lines]
>
> </asp:SqlDataSource>