Help with creating a Datagridview that is bound to an ObjectDataSourcehttp://forums.asp.net/t/1795172.aspx/1?Help+with+creating+a+Datagridview+that+is+bound+to+an+ObjectDataSourceSun, 22 Apr 2012 01:03:24 -040017951724943037http://forums.asp.net/p/1795172/4943037.aspx/1?Help+with+creating+a+Datagridview+that+is+bound+to+an+ObjectDataSourceHelp with creating a Datagridview that is bound to an ObjectDataSource <p>Hello ASP.Net,</p> <p>I have a website with a great deal of database tables and pages that interact with said tables. I have recently added a table to my database, it has the following schema:</p> <pre class="prettyprint">CREATE TABLE [dbo].[tblPCT]( [id] [uniqueidentifier] ROWGUIDCOL NOT NULL, [pct] [nvarchar](50) NULL, [credits] [smallint] NULL, [pctUser] [nvarchar](50) NULL, [pctPass] [nvarchar](25) NULL, [pctCode] [nchar](10) NULL, CONSTRAINT [PK_tblPCT] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]</pre> <p>I have a Dataset designed file located:</p> <p>App_Code/DAL/DAL.xsd</p> <p>This is where I drag on my table adapters and I create the Select/Update/Insert/Delete statements using the designer.</p> <p>On my aspx form, I drag on a DataDridView and an object data source, I assign the datagridview to the ODS and to the ODS I assign the table adapter I have generated in my DAL.xsd.</p> <p>All of the different columns/statements are autogenerated for me by vs2008.&nbsp;</p> <p>This is the markup:</p> <pre class="prettyprint">&lt;asp:Content ID="Content1" ContentPlaceHolderID="page_body" runat="Server"&gt; &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowSorting="True" DataKeyNames="id" DataSourceID="ObjectDataSource1"&gt; &lt;Columns&gt; &lt;asp:CommandField ShowDeleteButton="True" /&gt; &lt;asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" /&gt; &lt;asp:BoundField DataField="pct" HeaderText="pct" SortExpression="pct" /&gt; &lt;asp:BoundField DataField="credits" HeaderText="credits" SortExpression="credits" /&gt; &lt;asp:BoundField DataField="pctUser" HeaderText="pctUser" SortExpression="pctUser" /&gt; &lt;asp:BoundField DataField="pctPass" HeaderText="pctPass" SortExpression="pctPass" /&gt; &lt;asp:BoundField DataField="pctCode" HeaderText="pctCode" SortExpression="pctCode" /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="HealthDiagnosticsTableAdapters.tblPCTTableAdapter" UpdateMethod="Update" DataObjectTypeName="System.Guid"&gt; &lt;UpdateParameters&gt; &lt;asp:Parameter Name="id" DbType="Guid" /&gt; &lt;asp:Parameter Name="pct" Type="String" /&gt; &lt;asp:Parameter Name="credits" Type="Int16" /&gt; &lt;asp:Parameter Name="pctUser" Type="String" /&gt; &lt;asp:Parameter Name="pctPass" Type="String" /&gt; &lt;asp:Parameter Name="pctCode" Type="String" /&gt; &lt;asp:Parameter DbType="Guid" Name="Original_id" /&gt; &lt;/UpdateParameters&gt; &lt;InsertParameters&gt; &lt;asp:Parameter DbType="Guid" Name="id" /&gt; &lt;asp:Parameter Name="pct" Type="String" /&gt; &lt;asp:Parameter Name="credits" Type="Int16" /&gt; &lt;asp:Parameter Name="pctUser" Type="String" /&gt; &lt;asp:Parameter Name="pctPass" Type="String" /&gt; &lt;asp:Parameter Name="pctCode" Type="String" /&gt; &lt;/InsertParameters&gt; &lt;/asp:ObjectDataSource&gt; &lt;/asp:Content&gt; </pre> <p>When I try and delete a row I get the following error:</p> <h2><i>Could not find a property named 'id' on the type specified by the DataObjectTypeName property in ObjectDataSource 'ObjectDataSource1'.</i></h2> <p>Any suggestions welcome</p> 2012-04-20T13:36:45-04:004943047http://forums.asp.net/p/1795172/4943047.aspx/1?Re+Help+with+creating+a+Datagridview+that+is+bound+to+an+ObjectDataSourceRe: Help with creating a Datagridview that is bound to an ObjectDataSource <p>It appears that you have no DeleteParameters items.&nbsp; Add one for your id property and it should work.</p> <pre class="prettyprint">&lt;DeleteParameters&gt; &lt;asp:Parameter Name=&quot;id&quot; DbType=&quot;Guid&quot; /&gt; &lt;/UpdateParameters&gt;</pre> <p></p> 2012-04-20T13:44:44-04:004943066http://forums.asp.net/p/1795172/4943066.aspx/1?Re+Help+with+creating+a+Datagridview+that+is+bound+to+an+ObjectDataSourceRe: Help with creating a Datagridview that is bound to an ObjectDataSource <p>I have done the above as you have suggested, I changed the *UpdateParameters to *DeleteParameters and I still get the same error:</p> <h2><i>Could not find a property named 'id' on the type specified by the DataObjectTypeName property in ObjectDataSource 'ObjectDataSource1'.</i></h2> <p><span></span></p> 2012-04-20T13:57:16-04:004944111http://forums.asp.net/p/1795172/4944111.aspx/1?Re+Help+with+creating+a+Datagridview+that+is+bound+to+an+ObjectDataSourceRe: Help with creating a Datagridview that is bound to an ObjectDataSource <p>Don't change; add.&nbsp; You need parameters for Insert, Update, and Delete.</p> <p>When do you get the error above?</p> 2012-04-21T13:58:15-04:004944405http://forums.asp.net/p/1795172/4944405.aspx/1?Re+Help+with+creating+a+Datagridview+that+is+bound+to+an+ObjectDataSourceRe: Help with creating a Datagridview that is bound to an ObjectDataSource <p>Hello</p> <p>I notice that your generated value has an original_{0}So plz remove that by changing your codes like this following</p> <pre class="prettyprint">&lt;asp:ObjectDataSource ID=&quot;ObjectDataSource1&quot; runat=&quot;server&quot; DeleteMethod=&quot;Delete&quot; InsertMethod=&quot;Insert&quot; <strong>OldValuesParameterFormatString=&quot;original_{0}&quot; </strong>SelectMethod=&quot;GetData&quot; TypeName=&quot;HealthDiagnosticsTableAdapters.tblPCTTableAdapter&quot; UpdateMethod=&quot;Update&quot; DataObjectTypeName=&quot;System.Guid&quot;&gt; &lt;UpdateParameters&gt; &lt;asp:Parameter Name=&quot;id&quot; DbType=&quot;Guid&quot; /&gt; &lt;asp:Parameter Name=&quot;pct&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;credits&quot; Type=&quot;Int16&quot; /&gt; &lt;asp:Parameter Name=&quot;pctUser&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;pctPass&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;pctCode&quot; Type=&quot;String&quot; /&gt; <strong> </strong><strong>&lt;asp:Parameter DbType=&quot;Guid&quot; Name=&quot;Original_id&quot; /&gt;</strong> &lt;/UpdateParameters&gt;</pre> <pre class="prettyprint"><span class="tag">&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;</span></pre> <pre class="prettyprint"><span class="tag">And then make sure that your UpdateParameter should include all the above parameters with the same correct type in the function</span></pre> 2012-04-22T01:03:24-04:00