Когда я пытаюсь установить флажок в моем источнике данных, чтобы проверить оптимистичный параллелизм, я больше не могу редактировать данные. Я получаю сообщение об ошибке:
"Не задано значение для одного или нескольких обязательных параметров."
Я не уверен, как обойти это для моего sqldatasource1. Также, когда я пытаюсь вставить новую запись, мне не хватает поля для добавления идентификатора клиента? Ниже мой код. Извините, все еще новичок в этом.
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="CustomerMaintenanc.aspx.vb" Inherits="CustomerMaintenanc" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table border="0" cellpadding="0" cellspacing="0"><tr><td>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="CustomerID" DataSourceID="SqlDataSource2" ForeColor="#333333"
GridLines="None">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
<asp:CommandField ButtonType="Button" ShowSelectButton="True" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView></td><td valign=top align=right>
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
AutoGenerateRows="False" DataKeyNames="CustomerID"
DataSourceID="SqlDataSource1">
<Fields>
<asp:BoundField DataField="CustomerID" HeaderText="CustomerID"
InsertVisible="False" ReadOnly="True" SortExpression="CustomerID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
<asp:BoundField DataField="ZipCode" HeaderText="ZipCode"
SortExpression="ZipCode" />
<asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:CommandField ButtonType="Button" ShowDeleteButton="True"
ShowEditButton="True" ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:TechSupportConnectionString %>"
ProviderName="<%$ ConnectionStrings:TechSupportConnectionString.ProviderName %>"
SelectCommand="SELECT [CustomerID], [Name], [City], [State] FROM [Customers] ORDER BY [Name]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TechSupportConnectionString %>"
DeleteCommand="DELETE FROM [Customers] WHERE [CustomerID] = ? AND [Name] = ? AND [Address] = ? AND [City] = ? AND [State] = ? AND [ZipCode] = ? AND (([Phone] = ?) OR ([Phone] IS NULL AND ? IS NULL)) AND (([Email] = ?) OR ([Email] IS NULL AND ? IS NULL))"
InsertCommand="INSERT INTO [Customers] ([CustomerID], [Name], [Address], [City], [State], [ZipCode], [Phone], [Email]) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
ProviderName="<%$ ConnectionStrings:TechSupportConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Customers] WHERE ([CustomerID] = ?)"
UpdateCommand="UPDATE [Customers] SET [Name] = ?, [Address] = ?, [City] = ?, [State] = ?, [ZipCode] = ?, [Phone] = ?, [Email] = ? WHERE [CustomerID] = ? AND [Name] = ? AND [Address] = ? AND [City] = ? AND [State] = ? AND [ZipCode] = ? AND (([Phone] = ?) OR ([Phone] IS NULL AND ? IS NULL)) AND (([Email] = ?) OR ([Email] IS NULL AND ? IS NULL))"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="original_{0}">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="CustomerID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="original_CustomerID" Type="Int32" />
<asp:Parameter Name="original_Name" Type="String" />
<asp:Parameter Name="original_Address" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_State" Type="String" />
<asp:Parameter Name="original_ZipCode" Type="String" />
<asp:Parameter Name="original_Phone" Type="String" />
<asp:Parameter Name="original_Email" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="ZipCode" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="original_CustomerID" Type="Int32" />
<asp:Parameter Name="original_Name" Type="String" />
<asp:Parameter Name="original_Address" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_State" Type="String" />
<asp:Parameter Name="original_ZipCode" Type="String" />
<asp:Parameter Name="original_Phone" Type="String" />
<asp:Parameter Name="original_Email" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="CustomerID" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="ZipCode" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Email" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</td></tr></table>
</asp:Content>