Home All Groups Group Topic Archive Search About

GridView, ObjectDataSource, Update problems.

Author
14 Jul 2006 5:22 PM
Chris Szabo
Good morning everyone.  I have a problem right now using the GridView control
with and ObjectDataSource.  It appears as though the new values are not being
passed to the update method, only the original values.

I've stepped through the code, and I can see the new values correctly in the
GridView control, but when the Update method for the ODS is invoked, the
appropriate vales are not passed to the method.

Here is the markup:

            <asp:GridView
                OnPreRender="gvBom_OnPreRender"
                DataSourceID="odsGridSource"
                CssClass="dataGrid"
                Width="100%"
                AutoGenerateColumns="False"
                CellPadding="5"
                HorizontalAlign="Left"
                AutoGenerateEditButton="True"
                ID="gvBom"
                runat="server">
                <RowStyle CssClass="dataGridItemRow" Font-Size="X-Small" />
                <HeaderStyle BackColor="#F8F8F8" />
                <Columns>
                    <asp:BoundField Visible="false" DataField="ProductId" />
                    <asp:BoundField HeaderText="Product"
DataField="PartNumber" />
                    <asp:BoundField HeaderText="Qty" DataField="Quantity" />
                    <asp:BoundField HeaderText="Manufacturer"
DataField="Manufacturer" />
                    <asp:BoundField HeaderText="Clarification"
DataField="Clarification" />
                    <asp:BoundField HeaderText="Qty Available"
DataField="QuantityAvailable" />
                    <asp:BoundField HeaderText="Date Available"
DataField="DateAvailable" />
                    <asp:BoundField HeaderText="Extension"
DataField="Extension" />
                </Columns>
            </asp:GridView>
            <asp:ObjectDataSource
                ID="odsGridSource"
                runat="server"
                UpdateMethod="UpdateBomAddedProduct"
                SelectMethod="GetBomAddedProduct"
                TypeName="UI.BT.BOM.Processor" >
                <UpdateParameters>
                    <asp:Parameter Name="ProductId" Type="Int64" />
                    <asp:Parameter Name="PartNumber" Type="String" />
                    <asp:Parameter Name="Quantity" Type="Int32" />
                    <asp:Parameter Name="Manufacturer" Type="String" />
                    <asp:Parameter Name="Clarification" Type="String" />
                    <asp:Parameter Name="QuantityAvailable" Type="Int32" />
                    <asp:Parameter Name="DateAvailable" Type="DateTime" />
                    <asp:Parameter Name="Extension" Type="Int32" />
                </UpdateParameters>
            </asp:ObjectDataSource>

And this is the prototype for the method that is invoked in the business tier:

        public static void UpdateBomAddedProduct (
            Int64 ProductId,
            string PartNumber,
            int Quantity,
            string Manufacturer,
            string Clarification,
            int QuantityAvailable,
            DateTime DateAvailable,
            int Extension )
        { }

If a break point is set on this method, it will be hit.  But the values
being passed are the old values, not the updated values.  Does anyone have
any ideas on why this would happen?

Thanks

Author
14 Jul 2006 7:34 PM
Chris Szabo
I have some more information regarding this problem.  The GridView and the
ObjectDataSource are both located in a UserControl.  That control is embedded
within a templated cusom control, which is in a different UserControl.  The
tree would look like this:

-default.aspx
-------UserControl1
----------CustomControl1
----------------UserControl2
---------------------GridView
---------------------ObjectDataSource

If I copy and paste the GridView and ObjectDataSource into a test.aspx page,
everything functions perfectly.  Does anyone know if there are nesting issues
with these controls, or in .NET 2.0 in general?

Thanks for the help again.

Show quoteHide quote
"Chris Szabo" wrote:

> Good morning everyone.  I have a problem right now using the GridView control
> with and ObjectDataSource.  It appears as though the new values are not being
> passed to the update method, only the original values.
>
> I've stepped through the code, and I can see the new values correctly in the
> GridView control, but when the Update method for the ODS is invoked, the
> appropriate vales are not passed to the method.
>
> Here is the markup:
>
>             <asp:GridView
>                 OnPreRender="gvBom_OnPreRender"
>                 DataSourceID="odsGridSource"
>                 CssClass="dataGrid"
>                 Width="100%"
>                 AutoGenerateColumns="False"
>                 CellPadding="5"
>                 HorizontalAlign="Left"
>                 AutoGenerateEditButton="True"
>                 ID="gvBom"
>                 runat="server">
>                 <RowStyle CssClass="dataGridItemRow" Font-Size="X-Small" />
>                 <HeaderStyle BackColor="#F8F8F8" />
>                 <Columns>
>                     <asp:BoundField Visible="false" DataField="ProductId" />
>                     <asp:BoundField HeaderText="Product"
> DataField="PartNumber" />
>                     <asp:BoundField HeaderText="Qty" DataField="Quantity" />
>                     <asp:BoundField HeaderText="Manufacturer"
> DataField="Manufacturer" />
>                     <asp:BoundField HeaderText="Clarification"
> DataField="Clarification" />
>                     <asp:BoundField HeaderText="Qty Available"
> DataField="QuantityAvailable" />
>                     <asp:BoundField HeaderText="Date Available"
> DataField="DateAvailable" />
>                     <asp:BoundField HeaderText="Extension"
> DataField="Extension" />
>                 </Columns>
>             </asp:GridView>
>             <asp:ObjectDataSource
>                 ID="odsGridSource"
>                 runat="server"
>                 UpdateMethod="UpdateBomAddedProduct"
>                 SelectMethod="GetBomAddedProduct"
>                 TypeName="UI.BT.BOM.Processor" >
>                 <UpdateParameters>
>                     <asp:Parameter Name="ProductId" Type="Int64" />
>                     <asp:Parameter Name="PartNumber" Type="String" />
>                     <asp:Parameter Name="Quantity" Type="Int32" />
>                     <asp:Parameter Name="Manufacturer" Type="String" />
>                     <asp:Parameter Name="Clarification" Type="String" />
>                     <asp:Parameter Name="QuantityAvailable" Type="Int32" />
>                     <asp:Parameter Name="DateAvailable" Type="DateTime" />
>                     <asp:Parameter Name="Extension" Type="Int32" />
>                 </UpdateParameters>
>             </asp:ObjectDataSource>
>
> And this is the prototype for the method that is invoked in the business tier:
>
>         public static void UpdateBomAddedProduct (
>             Int64 ProductId,
>             string PartNumber,
>             int Quantity,
>             string Manufacturer,
>             string Clarification,
>             int QuantityAvailable,
>             DateTime DateAvailable,
>             int Extension )
>         { }
>
> If a break point is set on this method, it will be hit.  But the values
> being passed are the old values, not the updated values.  Does anyone have
> any ideas on why this would happen?
>
> Thanks
>
Author
25 Jul 2006 6:36 PM
objectdatasource control update
I'm having exactly the same problem.  Did you find a fix?  Thanks!

Rob
robert.r***@valmont.com