473,395 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ASP.NET 2.0 ObjectDataSource UpdateMethod not passing new values

Hello,

I started working with the ObjectDataSource today. I have the select,
and have been working on getting the update method to work. Here is
the asp code for my Data source:

<asp:ObjectDataSource ID="dsourceApps" runat="server"
SelectMethod="getAllApplications"
TypeName="AppMgr.AppManager" UpdateMethod="updateAppHdr"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="{0}_old"
OnObjectCreating="dsourceApps_OnObjectCreating"
OnObjectDisposing="dsourceApps_OnObjectDisposing">
<UpdateParameters>
<asp:Parameter Name="appid" Type="String" />
<asp:Parameter Name="appname" Type="String" />
<asp:Parameter Name="apploc" Type="String" />
<asp:Parameter Name="appdesc" Type="String" />
<asp:Parameter Name="appid_old" Type="String" />
<asp:Parameter Name="appname_old" Type="String" />
<asp:Parameter Name="apploc_old" Type="String" />
<asp:Parameter Name="appdesc_old" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
The function sig for the updateAppHdr function is:

public void updateAppHdr(string appid, string appname, string apploc,
string appdesc, string appid_old, string appname_old, string
apploc_old, string appdesc_old)

The error that I get after I hit the save button after editing a field
in my GridView is:

Exception Details: System.Data.OracleClient.OracleException: ORA-06550:
line 1, column 7:
PLS-00306: wrong number or types of arguments in call to
'ND_UPD_DEFINED_APP'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
I did some digging, and I'm noticing that all the new values (the
fields without "_old" appended) are coming into the function as NULL.
The old values are coming in properly, but the new values are just
null...

Any ideas why this is happening? It's actually getting into the
function, so I'm guessing it has something to do with the way the
gridview is setup... I can't seem to find anything on this on google,
or maybe I'm just not sure what to look for...

Thanks in advance for any help,
Mike

Jan 20 '06 #1
13 8182
In the UpdateAppHdr function can you try setting the values to defaults (if
they were null) before passing them to Oracle and see if that eliminates the
ORA exception?

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"an*******@gmail.com" wrote:
Hello,

I started working with the ObjectDataSource today. I have the select,
and have been working on getting the update method to work. Here is
the asp code for my Data source:

<asp:ObjectDataSource ID="dsourceApps" runat="server"
SelectMethod="getAllApplications"
TypeName="AppMgr.AppManager" UpdateMethod="updateAppHdr"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="{0}_old"
OnObjectCreating="dsourceApps_OnObjectCreating"
OnObjectDisposing="dsourceApps_OnObjectDisposing">
<UpdateParameters>
<asp:Parameter Name="appid" Type="String" />
<asp:Parameter Name="appname" Type="String" />
<asp:Parameter Name="apploc" Type="String" />
<asp:Parameter Name="appdesc" Type="String" />
<asp:Parameter Name="appid_old" Type="String" />
<asp:Parameter Name="appname_old" Type="String" />
<asp:Parameter Name="apploc_old" Type="String" />
<asp:Parameter Name="appdesc_old" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
The function sig for the updateAppHdr function is:

public void updateAppHdr(string appid, string appname, string apploc,
string appdesc, string appid_old, string appname_old, string
apploc_old, string appdesc_old)

The error that I get after I hit the save button after editing a field
in my GridView is:

Exception Details: System.Data.OracleClient.OracleException: ORA-06550:
line 1, column 7:
PLS-00306: wrong number or types of arguments in call to
'ND_UPD_DEFINED_APP'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
I did some digging, and I'm noticing that all the new values (the
fields without "_old" appended) are coming into the function as NULL.
The old values are coming in properly, but the new values are just
null...

Any ideas why this is happening? It's actually getting into the
function, so I'm guessing it has something to do with the way the
gridview is setup... I can't seem to find anything on this on google,
or maybe I'm just not sure what to look for...

Thanks in advance for any help,
Mike

Jan 20 '06 #2
Thanks Phillip, I was away for a few days or I would have replied
sooner.

I did what you suggested, in the function to do the update, I went
ahead and hardcoded some values for the "new" fields (bypassing the
NULL's that were coming in) and the stored proc fired and executed just
fine.

The problem has to be with the null's getting passed in, but I can't
seem to track it down yet. Any more suggestions?

Thanks,
Mike

Jan 25 '06 #3
Welcome back Mike.

My first guess would be the 2-way databinding. The ObjectDataSource would
pass null for the parameter values if the databound server control was not
using 2-way databinding, e.g. if you had used itemtemplates in the GridView
with controls bound using the Eval method instead of the Bind, e.g.:
<asp:TextBox ID="txtapploc" runat="server" Text='<%# Eval("apploc"")
%>'></asp:TextBox>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Mike" wrote:
Thanks Phillip, I was away for a few days or I would have replied
sooner.

I did what you suggested, in the function to do the update, I went
ahead and hardcoded some values for the "new" fields (bypassing the
NULL's that were coming in) and the stored proc fired and executed just
fine.

The problem has to be with the null's getting passed in, but I can't
seem to track it down yet. Any more suggestions?

Thanks,
Mike

Jan 25 '06 #4
Hi again Phillip...

I did some googling, but I'm not understanding what you mean by this...
how do I implement 2 way databinding between the gridview and my
object? By using itemtemplates?

I'll keep looking, and thanks again for your help,
Mike
Phillip Williams wrote:
Welcome back Mike.

My first guess would be the 2-way databinding. The ObjectDataSource would
pass null for the parameter values if the databound server control was not
using 2-way databinding, e.g. if you had used itemtemplates in the GridView
with controls bound using the Eval method instead of the Bind, e.g.:
<asp:TextBox ID="txtapploc" runat="server" Text='<%# Eval("apploc"")
%>'></asp:TextBox>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Mike" wrote:
Thanks Phillip, I was away for a few days or I would have replied
sooner.

I did what you suggested, in the function to do the update, I went
ahead and hardcoded some values for the "new" fields (bypassing the
NULL's that were coming in) and the stored proc fired and executed just
fine.

The problem has to be with the null's getting passed in, but I can't
seem to track it down yet. Any more suggestions?

Thanks,
Mike


Jan 25 '06 #5
The 2-way databinding happens when the GridView automatic update is enabled:
“The automatic updating, deleting, and selection functionalities are enabled
when a button in a ButtonField or TemplateField column field, with a command
name of "Edit", "Delete", and "Select", respectively, is clicked. The
GridView control can automatically add a CommandField column field with an
Edit, Delete, or Select button if the AutoGenerateEditButton,
AutoGenerateDeleteButton, or AutoGenerateSelectButton property is set to
true, respectively.”
http://msdn2.microsoft.com/en-us/library/4w7ya1ts.aspx

In editing columns in a GridView one might use a BoundField or a customized
EditItemTemplate combination. If you use the BoundField and want to enable
the 2-way databinding make sure that the ReadOnly property is not set to true
(the default value is false). If you used a customized EditItemTemplate
(like I did in this demo
http://www.webswapp.com/CodeSamples/...idView_2c.aspx) then make sure
that you used Bind not Eval to set the values of the TextBoxes.

If this information does not help you solve the problem, you may want to
post the markup for the GridView so that I can take a second look on it for
you.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Mike" wrote:
Hi again Phillip...

I did some googling, but I'm not understanding what you mean by this...
how do I implement 2 way databinding between the gridview and my
object? By using itemtemplates?

I'll keep looking, and thanks again for your help,
Mike
Phillip Williams wrote:
Welcome back Mike.

My first guess would be the 2-way databinding. The ObjectDataSource would
pass null for the parameter values if the databound server control was not
using 2-way databinding, e.g. if you had used itemtemplates in the GridView
with controls bound using the Eval method instead of the Bind, e.g.:
<asp:TextBox ID="txtapploc" runat="server" Text='<%# Eval("apploc"")
%>'></asp:TextBox>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Mike" wrote:
Thanks Phillip, I was away for a few days or I would have replied
sooner.

I did what you suggested, in the function to do the update, I went
ahead and hardcoded some values for the "new" fields (bypassing the
NULL's that were coming in) and the stored proc fired and executed just
fine.

The problem has to be with the null's getting passed in, but I can't
seem to track it down yet. Any more suggestions?

Thanks,
Mike


Jan 25 '06 #6
I checked out your source, and cannot see anything that you're really
doing different than me. I even changed an item to be a template
column and that did nothing for me as well...

Below is my markup for the gridview and datasource... Thanks again!

--------------------------------------------------
<asp:GridView ID="gvAppList" runat="server" AllowPaging="True"
AllowSorting="True"
Caption="Application List" CssClass="tabledisplay"
DataSourceID="dsourceApps"
HorizontalAlign="Center" PageSize="5" Width="95%"
CaptionAlign="Top" CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="False"
OnRowUpdating="gvAppList_OnRowUpdating"
AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
AutoGenerateSelectButton="True">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="APPID" HeaderText="App ID"
SortExpression="appid" ApplyFormatInEditMode="True" />
<asp:TemplateField HeaderText="Name"
SortExpression="APPNAME">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("APPNAME") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("APPNAME") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="APPLOC" HeaderText="Location"
SortExpression="APPLOC" />
<asp:BoundField DataField="APPDESC"
HeaderText="Description" SortExpression="APPDESC" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<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="dsourceApps" runat="server"
SelectMethod="getAllApplications"
TypeName="AppMgr.AppManager" UpdateMethod="updateAppHdr"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="{0}_old"
OnObjectCreating="dsourceApps_OnObjectCreating"
OnObjectDisposing="dsourceApps_OnObjectDisposing">
<UpdateParameters>
<asp:Parameter Name="appid" Type="String" />
<asp:Parameter Name="appname" Type="String" />
<asp:Parameter Name="apploc" Type="String" />
<asp:Parameter Name="appdesc" Type="String" />
<asp:Parameter Name="appid_old" Type="String" />
<asp:Parameter Name="appname_old" Type="String" />
<asp:Parameter Name="apploc_old" Type="String" />
<asp:Parameter Name="appdesc_old" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
---------------------------------------

Jan 26 '06 #7
Hi Mike,

Using the code that you posted, I can only reproduce the situation that you
get if I turn the EnableViewState to false.

Here is your code working as expected:
http://www.webswapp.com/CodeSamples/...tate_true.aspx

Here is your code working as you described:
http://www.webswapp.com/CodeSamples/...ate_false.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Mike" wrote:
I checked out your source, and cannot see anything that you're really
doing different than me. I even changed an item to be a template
column and that did nothing for me as well...

Below is my markup for the gridview and datasource... Thanks again!

--------------------------------------------------
<asp:GridView ID="gvAppList" runat="server" AllowPaging="True"
AllowSorting="True"
Caption="Application List" CssClass="tabledisplay"
DataSourceID="dsourceApps"
HorizontalAlign="Center" PageSize="5" Width="95%"
CaptionAlign="Top" CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="False"
OnRowUpdating="gvAppList_OnRowUpdating"
AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
AutoGenerateSelectButton="True">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="APPID" HeaderText="App ID"
SortExpression="appid" ApplyFormatInEditMode="True" />
<asp:TemplateField HeaderText="Name"
SortExpression="APPNAME">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("APPNAME") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("APPNAME") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="APPLOC" HeaderText="Location"
SortExpression="APPLOC" />
<asp:BoundField DataField="APPDESC"
HeaderText="Description" SortExpression="APPDESC" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<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="dsourceApps" runat="server"
SelectMethod="getAllApplications"
TypeName="AppMgr.AppManager" UpdateMethod="updateAppHdr"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="{0}_old"
OnObjectCreating="dsourceApps_OnObjectCreating"
OnObjectDisposing="dsourceApps_OnObjectDisposing">
<UpdateParameters>
<asp:Parameter Name="appid" Type="String" />
<asp:Parameter Name="appname" Type="String" />
<asp:Parameter Name="apploc" Type="String" />
<asp:Parameter Name="appdesc" Type="String" />
<asp:Parameter Name="appid_old" Type="String" />
<asp:Parameter Name="appname_old" Type="String" />
<asp:Parameter Name="apploc_old" Type="String" />
<asp:Parameter Name="appdesc_old" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
---------------------------------------

Jan 26 '06 #8
Phillip,

I went back and explicitely set the EnableViewState="true" on the page,
masterpage, and gridview control, but still no go. I can see that it
works for you, but for some reason still no go here... I can see in the
page source when it's rendered in a browser that I am getting the
viewstate in the browser, I thought maybe it's getting "lost" somewhere
in the three page loads that happen, but I can't seem to view the
ViewState variable running in Debug mode (I'm not adding anything to it
through the code, so I probably just can't see what .NET adds to it
internally)...

I guess I'll try to do it without the Masterpage and see if I can't get
it to work...

I'll post back in a bit..

Jan 26 '06 #9
I took the code out of the masterpage and put it in it's own page,
hooked up the necessary events and fired it off and the values are
coming through fine, just like on your site.

So I guess now the question moves on to why is the masterpage messing
with my viewstate values on the return?

Thanks again for your help,
Mike

Jan 26 '06 #10
Hello Mike,

Placing the code within the masterpage (in itself) should not be the cause
of the problem. Here is the same demo with the code moved to the master page
and it is still working:
http://www.webswapp.com/CodeSamples/...ate_true2.aspx

The page's EnableViewState setting should override the web.config file
setting, so even if your web.config filehad a line like this:
<pages EnableViewState="false">

your master page should have still worked if your page specifically had the
enableViewState=”true”

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Mike" wrote:
I took the code out of the masterpage and put it in it's own page,
hooked up the necessary events and fired it off and the values are
coming through fine, just like on your site.

So I guess now the question moves on to why is the masterpage messing
with my viewstate values on the return?

Thanks again for your help,
Mike

Jan 26 '06 #11
I should have explained that better... the datagrid is on a content
page, using a masterpage, not on the masterpage itself. Of course, I
cannot see why this would be the problem, but when I copy the code out
of the content page onto a regular page (not using a masterpage)
verbatim, it works.

Is there a way for me to view the viewstate (what's being sent back
from the browser) while in debug mode? Maybe I can watch it through
execution after clicking update and see where it might be getting
cleared.

Jan 26 '06 #12
Phillip,

I found the cause. There's a user control in my master page that holds
a username/password (login-type) area. This is all that is going into
the viewstate (found it in the trace output), so when I'm clicking the
update button on the grid, it's not sending those updated values back
(the viewstate only contains the username & password fields).

I removed the username/pw form and tried again, and sure enough, the
values got passed properly.

Off to figure out why ... Thanks again very much for all the help, I
greatly appreciate it.

Mike

Jan 26 '06 #13
You are very welcome.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Mike" wrote:
Phillip,

I found the cause. There's a user control in my master page that holds
a username/password (login-type) area. This is all that is going into
the viewstate (found it in the trace output), so when I'm clicking the
update button on the grid, it's not sending those updated values back
(the viewstate only contains the username & password fields).

I removed the username/pw form and tried again, and sure enough, the
values got passed properly.

Off to figure out why ... Thanks again very much for all the help, I
greatly appreciate it.

Mike

Jan 26 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
5
by: Ole M | last post by:
I'm having some trouble using the ObjectDataSource in ASP.NET 2.0. I have a wrapper that contains the static methods for Select and Update. The Update-method takes the business object as...
5
by: Dabbler | last post by:
What is the best way to handle data interpolation between form controls and the actual sql data field. I have radio buttons that need to be interpreted, form values that have to be translated.....
3
by: Jeronimo Bertran | last post by:
I have a FormView that shows details of a specific record on a table. The SelecMethod returns a DataSet that includes all the fields from my Event table and other read-only fields from linked...
2
by: J055 | last post by:
Hi I have a method with the following signature: public bool UpdateSetAccounts(int items) { } How do I pass a collection of selected values in a ListBox to this ObjectDataSource...
1
by: =?Utf-8?B?cm9zczYxMw==?= | last post by:
I really hope this is not a case of "this silly thing will never work".....lots of time invested in troubleshooting this already. I have created a standard ASP.NET web form (.aspx) with several...
4
by: tim.cavins | last post by:
I have a GridView populated by an ObjectDataSource. I am having issues passing the parameters to the objectdatasource. I have verified that the method is being called but none of the parameters...
9
by: Kernel Bling | last post by:
Hi Everyone, This Saturday the stage was set. The problem simply could not go on existing -- it had to be solved. Many hours, articles, compilations and frustrations later I still did not find...
0
by: steve | last post by:
I have been fighting with trying to update a GridView for a while. I don't want to use the "built-in" way to do it because I am using business layer methods for updating and deleteing and I don't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.