Привет.
Использую АСП.НЕТ 3.5 МССКЛ 2005
Когда удаляю происходит ошибка:
You have specified that your delete command compares all values on SqlDataSource 'SqlDataSource1', but the dictionary passed in for values is empty. Pass in a valid dictionary for delete or change your mode to OverwriteChanges.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: You have specified that your delete command compares all values on SqlDataSource 'SqlDataSource1', but the dictionary passed in for values is empty. Pass in a valid dictionary for delete or change your mode to OverwriteChanges.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Попробывал поменять ConflictDetection="CompareAllValues" на ConflictDetection="OverwriteChanges",
тогда просто ничего не происхолид(не удаляет то есть)
Хелп плз!
Мой код:
aspx:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:LocalSqlServer %>"
OldValuesParameterFormatString="original_{0}"
OnSelecting="SqlDataSource2_Selecting"
DeleteCommand="DELETE FROM [message] WHERE ([message].[id_mes] = @id_mes)"
SelectCommand="
SELECT
[message].[id_mes],
[message].[body_mes],
[message].[date_mes],
[message].[name_mes],
[message].[namef_mes],
(SELECT IsNull(COUNT(*), 0) FROM [sec] WHERE [name] = @name_mes) [secCount],
(SELECT IsNull(avatar_prof, 0) FROM [prof] WHERE [name_prof] = [message].[namef_mes]) [avatar_prof]
FROM [message]
WHERE ([name_mes] = @name_mes)
ORDER by [message].[id_mes] ASC">
<SelectParameters>
<asp:Parameter Name="name_mes" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="id_mes" />
</DeleteParameters>
</asp:SqlDataSource>
aspx.cs:
protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
MembershipUser currentUser = Membership.GetUser();
e.Command.Parameters["@name_mes"].Value = currentUser.UserName;
}