Discussion:
Problem with objectdatasource always passing zero to delete command from gridview
Dan
2007-05-02 04:04:03 UTC
Permalink
Hi guys im having problems with the dreaded objectdatasource. Using custom
objects generated with subsonic im trying to get a gridview to handle the
deleting of objects using the objectdatasource component. For some reason
when i click the delete button on the searchcriteria gridview it always
passes zero to the delete command. Before the commands parameters were an
object key and for that it always passed null to the command. Updating and
inserting work fine, its just the delete that always passes bad data to the
delete command. Anyone have any ideas that might help?


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="Ezibuy.Sortation.WebApp._Default" Theme="default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Sortation Filter</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Image ID="Image1" runat="server"
ImageUrl="~/images/ezibuylogo.gif" />
<div class="header">Sortation Filter</div>
<br />
<div class="options">
<fieldset style="width: 201px" >
<legend>View Options</legend>
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal" AutoPostBack="True"
OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Selected="True">Unmatched</asp:ListItem>
<asp:ListItem>Matched</asp:ListItem>
</asp:RadioButtonList>
</fieldset></div><br />

<div class="subheader">Create New Filter</div>
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True"
AutoGenerateRows="False"
CellPadding="4" DataSourceID="ObjectDataSource1"
ForeColor="#333333" GridLines="None"
Height="50px" Width="46%" DefaultMode="Insert">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
<EditRowStyle BackColor="#2461BF" />
<RowStyle BackColor="#EFF3FB" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<Fields>
<asp:BoundField DataField="CreatedBy" HeaderText="CreatedBy"
SortExpression="CreatedBy"
Visible="False" />
<asp:BoundField DataField="ModifiedOn"
HeaderText="ModifiedOn" SortExpression="ModifiedOn"
Visible="False" />
<asp:BoundField DataField="SORTCODE" HeaderText="SORTCODE"
SortExpression="SORTCODE" >
<ControlStyle Width="200px" />
</asp:BoundField>
<asp:BoundField DataField="CreatedOn" HeaderText="CreatedOn"
SortExpression="CreatedOn"
Visible="False" />
<asp:BoundField DataField="SEARCHTEXT"
HeaderText="SEARCHTEXT" SortExpression="SEARCHTEXT" >
<ControlStyle Width="300px" />
</asp:BoundField>
<asp:BoundField DataField="ModifiedBy"
HeaderText="ModifiedBy" SortExpression="ModifiedBy"
Visible="False" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:DetailsView>
<br />
<div class="subheader">Current Filters</div>
<asp:GridView ID="GridView2" runat="server"
AutoGenerateColumns="False"
CellPadding="4" DataSourceID="ObjectDataSource1"
ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID"
SortExpression="ID" />
<asp:BoundField DataField="SEARCHTEXT"
HeaderText="SEARCHTEXT" SortExpression="SEARCHTEXT" >
<ControlStyle Width="300px" />
</asp:BoundField>
<asp:BoundField DataField="SORTCODE" HeaderText="SORTCODE"
SortExpression="SORTCODE" />
</Columns>

<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="Delete"
InsertMethod="Insert" ConflictDetection="OverwriteChanges"
SelectMethod="FetchAll"
TypeName="Ezibuy.Sortation.Framework.SEARCHCRITERIAController"
UpdateMethod="Update" OnDeleting="ObjectDataSource1_Deleting1">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="SEARCHTEXT" Type="String" />
<asp:Parameter Name="SORTCODE" Type="String" />
<asp:Parameter Name="CreatedOn" Type="DateTime" />
<asp:Parameter Name="CreatedBy" Type="String" />
<asp:Parameter Name="ModifiedOn" Type="DateTime" />
<asp:Parameter Name="ModifiedBy" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="SEARCHTEXT" Type="String" />
<asp:Parameter Name="SORTCODE" Type="String" />
<asp:Parameter Name="CreatedOn" Type="DateTime" />
<asp:Parameter Name="CreatedBy" Type="String" />
<asp:Parameter Name="ModifiedOn" Type="DateTime" />
<asp:Parameter Name="ModifiedBy" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
<br />
<div class="subheader">Unmatched Addresses</div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
GridLines="None" AllowSorting="True" PageSize="50">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<Columns>
<asp:BoundField DataField="Recnum" HeaderText="Recnum" />
<asp:BoundField DataField="ExternOrderKey" HeaderText="Key"
/>
<asp:BoundField DataField="FullAddress" HeaderText="Address"
/>
<asp:BoundField DataField="SORTCODE" HeaderText="SortCode"
/>
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
&nbsp;

</div>
</form>
</body>
</html>

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Christopher Frazier
2007-05-02 21:14:00 UTC
Permalink
I don't know if this will help, but subsonic just released v2.0 which claims
to have better ODS support

http://www.codeplex.com/actionpack/Release/ProjectReleases.aspx?ReleaseId=38
12

--
-Christopher
| AspInsider
http://chrisfrazier.net/blog

(\__/)
(='.'=) This is Bunny. Copy and paste bunny into your
(")_(") signature to help him gain world domination.

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Dan
Sent: Tuesday, May 01, 2007 11:04 PM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: [DOTNET-WEB] Problem with objectdatasource always passing zero to
delete command from gridview

Hi guys im having problems with the dreaded objectdatasource. Using custom
objects generated with subsonic im trying to get a gridview to handle the
deleting of objects using the objectdatasource component. For some reason
when i click the delete button on the searchcriteria gridview it always
passes zero to the delete command. Before the commands parameters were an
object key and for that it always passed null to the command. Updating and
inserting work fine, its just the delete that always passes bad data to the
delete command. Anyone have any ideas that might help?


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="Ezibuy.Sortation.WebApp._Default" Theme="default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Sortation Filter</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Image ID="Image1" runat="server"
ImageUrl="~/images/ezibuylogo.gif" />
<div class="header">Sortation Filter</div>
<br />
<div class="options">
<fieldset style="width: 201px" >
<legend>View Options</legend>
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal" AutoPostBack="True"
OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Selected="True">Unmatched</asp:ListItem>
<asp:ListItem>Matched</asp:ListItem>
</asp:RadioButtonList>
</fieldset></div><br />

<div class="subheader">Create New Filter</div>
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True"
AutoGenerateRows="False"
CellPadding="4" DataSourceID="ObjectDataSource1"
ForeColor="#333333" GridLines="None"
Height="50px" Width="46%" DefaultMode="Insert">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
<EditRowStyle BackColor="#2461BF" />
<RowStyle BackColor="#EFF3FB" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<Fields>
<asp:BoundField DataField="CreatedBy" HeaderText="CreatedBy"
SortExpression="CreatedBy"
Visible="False" />
<asp:BoundField DataField="ModifiedOn"
HeaderText="ModifiedOn" SortExpression="ModifiedOn"
Visible="False" />
<asp:BoundField DataField="SORTCODE" HeaderText="SORTCODE"
SortExpression="SORTCODE" >
<ControlStyle Width="200px" />
</asp:BoundField>
<asp:BoundField DataField="CreatedOn" HeaderText="CreatedOn"
SortExpression="CreatedOn"
Visible="False" />
<asp:BoundField DataField="SEARCHTEXT"
HeaderText="SEARCHTEXT" SortExpression="SEARCHTEXT" >
<ControlStyle Width="300px" />
</asp:BoundField>
<asp:BoundField DataField="ModifiedBy"
HeaderText="ModifiedBy" SortExpression="ModifiedBy"
Visible="False" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:DetailsView>
<br />
<div class="subheader">Current Filters</div>
<asp:GridView ID="GridView2" runat="server"
AutoGenerateColumns="False"
CellPadding="4" DataSourceID="ObjectDataSource1"
ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID"
SortExpression="ID" />
<asp:BoundField DataField="SEARCHTEXT"
HeaderText="SEARCHTEXT" SortExpression="SEARCHTEXT" >
<ControlStyle Width="300px" />
</asp:BoundField>
<asp:BoundField DataField="SORTCODE" HeaderText="SORTCODE"
SortExpression="SORTCODE" />
</Columns>

<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="Delete"
InsertMethod="Insert" ConflictDetection="OverwriteChanges"
SelectMethod="FetchAll"
TypeName="Ezibuy.Sortation.Framework.SEARCHCRITERIAController"
UpdateMethod="Update" OnDeleting="ObjectDataSource1_Deleting1">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="SEARCHTEXT" Type="String" />
<asp:Parameter Name="SORTCODE" Type="String" />
<asp:Parameter Name="CreatedOn" Type="DateTime" />
<asp:Parameter Name="CreatedBy" Type="String" />
<asp:Parameter Name="ModifiedOn" Type="DateTime" />
<asp:Parameter Name="ModifiedBy" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="SEARCHTEXT" Type="String" />
<asp:Parameter Name="SORTCODE" Type="String" />
<asp:Parameter Name="CreatedOn" Type="DateTime" />
<asp:Parameter Name="CreatedBy" Type="String" />
<asp:Parameter Name="ModifiedOn" Type="DateTime" />
<asp:Parameter Name="ModifiedBy" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
<br />
<div class="subheader">Unmatched Addresses</div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
GridLines="None" AllowSorting="True" PageSize="50">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<Columns>
<asp:BoundField DataField="Recnum" HeaderText="Recnum" />
<asp:BoundField DataField="ExternOrderKey" HeaderText="Key"
/>
<asp:BoundField DataField="FullAddress" HeaderText="Address"
/>
<asp:BoundField DataField="SORTCODE" HeaderText="SortCode"
/>
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
&nbsp;

</div>
</form>
</body>
</html>

===================================
This list is hosted by DevelopMentorR http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Loading...