I have a problem with my delete parameter. I am using a GridView and a ObjectDataSource. And I would like to delete one row. But when I debug is see that the value of CustomerId is always 0 in my Business Logic Layer.
我的法典
我有两个删除参数:Id
和。 这些名字与我的《维也纳条约法公约》中的名称相同。
<asp:GridView DataKeyNames="Id" ID="gvFavoriteMovies" DataSourceID="odsFavoriteMovies" AutoGenerateColumns="False"
runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblTitel" runat="server" Text= <%# DataBinder.Eval(Container.DataItem, "Title")%> ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="odsFavoriteFilm" runat="server"
TypeName="MovieMonstrDataLayer.bll.BLLMovies"
SelectMethod="GetFavoriteMoviesFromUser"
DeleteMethod="DeleteFavoriteMoviesFromUser"
onobjectcreating="odsFavoriteFilm_ObjectCreating"
ondeleting="odsFavoriteFilm_Deleting">
<DeleteParameters>
<asp:Parameter Name="Id" DbType="Int32" Direction="Input" />
<asp:Parameter Name="CustomerId" DbType="Int32" Direction="Input" />
</DeleteParameters>
<SelectParameters>
<asp:Parameter DbType="Int32" Direction="Input" Name="CustomerId" />
</SelectParameters>
</asp:ObjectDataSource>
这在档案背后的法典中。
在删除行文时,我把贴在客户中的标记的价值分配给删除参数<条码>。 所有这一切都奏效。 我请删除参数。
protected void odsFavoriteFilm_Deleting(object sender, ObjectDataSourceMethodEventArgs e)
{
if (Context.User.Identity.IsAuthenticated)
{
this.odsFavoriteFilm.DeleteParameters["CustomerId"].DefaultValue = ((MovieMonstrIdentity)Context.User.Identity).Customer.Id.ToString();
this.odsFavoriteFilm.DataBind();
}
}
通常,在我的商业界,我现在要获得正确的<条码>。 0. 虽然没有计票员。
public int DeleteFavoriteFilmFromUser(int Id, int CustomerId)
{
try
{
return Adapter.DeleteFavoriteFilmFromUser(Id, CustomerId);
}
catch (Exception ex)
{
throw ex;
}
}
What am I doing wrong?