У меня есть asp.net Formview, подключенный к источнику данных SQL. Когда я создаю/редактирую/удаляю запись, данные столбца стираются. Я уверен, что это просто неправильное кодирование, так как все, что я знаю о SQL/asp.net, было нагуглено за последние пару недель.
Вот код SQLDataSource.
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:hulc01ConnectionString %>"
SelectCommand="SELECT * FROM [Common]"
InsertCommand="INSERT INTO [Common] ([Project_Name],
[Business_Category], [Project_Description], [Operations_Owner])
VALUES (@ProjectName, @BusinessCategory, @ProjectDescription,
@OperationsOwner)"
DeleteCommand="DELETE FROM [Common] WHERE [ProjectKey] = @ProjectKey"
UpdateCommand="UPDATE [Common]
SET
[Project_Name] = @ProjectName,
[Business_Category] = @BusinessCategory,
[Project_Description] = @ProjectDescription,
[Operations_Owner] = @OperationsOwner
WHERE ProjectKey=@ProjectKey" >
<DeleteParameters>
<asp:Parameter Name="ProjectKey" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ProjectKey" Type="Int32" />
<asp:Parameter Name="ProjectName" Type="String" />
<asp:Parameter Name="BusinessCategory" Type="String" />
<asp:Parameter Name="ProjectDescription" Type="String" />
<asp:Parameter Name="OperationsOwner" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ProjectName" Type="String" />
<asp:Parameter Name="BusinessCategory" Type="String" />
<asp:Parameter Name="ProjectDescription" Type="String" />
<asp:Parameter Name="OperationsOwner" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
А вот код formview
<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
DataKeyNames="ProjectKey"
DataSourceID="SqlDataSource1"
Width="249px">
<EditItemTemplate>
Project Name:
<asp:TextBox runat="server"
ID="ProjectName"
Text='<%# Bind("Project_Name") %>' />
<br />
Business Category:
<asp:TextBox runat="server"
ID="BusinessCategory"
Text='<%# Bind("Business_Category") %>' />
<br />
Project Description:
<asp:TextBox runat="server"
ID="ProjectDescription"
Text='<%# Bind("Project_Description") %>' />
<br />
Operations Owner:
<asp:TextBox runat="server"
ID="OwnerTextBox"
Text='<%# Bind("Operations_Owner") %>' />
<br />
<asp:LinkButton runat="server"
ID="UpdateButton"
CausesValidation="True"
CommandName="Update"
Text="Update" />
<asp:LinkButton runat="server"
ID="UpdateCancelButton"
CausesValidation="False"
CommandName="Cancel"
Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
Project Name:
<asp:TextBox runat="server"
ID="ProjectName"
Text='<%# Bind("Project_Name") %>' />
<br />
Business Category:
<asp:TextBox runat="server"
ID="BusinessCategory"
Text='<%# Bind("Business_Category") %>' />
<br />
Project Description:
<asp:TextBox runat="server"
ID="Description"
Text='<%# Bind("Project_Description") %>' />
<br />
Operations Owner:
<asp:TextBox runat="server"
ID="TitleTextBox"
Text='<%# Bind("Operations_Owner") %>' />
<br />
<asp:LinkButton runat="server"
ID="InsertButton"
CausesValidation="True"
CommandName="Insert"
Text="Insert" />
<asp:LinkButton runat="server"
ID="InsertCancelButton"
CausesValidation="False"
CommandName="Cancel"
Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
Project Name:
<asp:Label runat="server"
ID="ProjectNameLabel"
Text='<%# Bind("Project_Name") %>' />
<br />
Business Category:
<asp:Label runat="server"
ID="BusinessCategoryLabel"
Text='<%# Bind("Business_Category") %>' />
<br />
Project Description:
<asp:Label runat="server"
ID="ProjectDescriptionLabel"
Text='<%# Bind("Project_Description") %>' />
<br />
Operations Owner:
<asp:Label runat="server"
ID="OwnerLabel"
Text='<%# Bind("Operations_Owner") %>' />
<br />
<asp:LinkButton runat="server"
ID="EditButton"
CausesValidation="False"
CommandName="Edit"
Text="Edit" />
<asp:LinkButton runat="server"
ID="DeleteButton"
CausesValidation="False"
CommandName="Delete" Text="Delete" />
<asp:LinkButton runat="server"
ID="NewButton"
CausesValidation="False"
CommandName="New"
Text="New" />
</ItemTemplate>
</asp:FormView>
Спасибо!