Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > FormView update not updating with ObjectDataSource

Reply
Thread Tools

FormView update not updating with ObjectDataSource

 
 
=?Utf-8?B?RGFiYmxlcg==?=
Guest
Posts: n/a
 
      04-13-2006
I have a FormView tied to ObjectDataSource that's not updating and am
wondering what I missed..

<asp:FormView ID="fvRegDetail" runat="server" DefaultMode="Edit"
DataKeyNames="RegistrantId" DataSourceID="odsRegistrant"
CssClass="waFormView" >
<EditItemTemplate>
....
<asp:Button ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" ValidationGroup="regForm">
</asp:Button>

<asp:ObjectDataSource ID="odsRegistrant" runat="server"
TypeName="RegistrantDB" SelectMethod="GetRegistrant"
UpdateMethod="UpdateRegistrant" DataObjectTypeName="RegistrantDetails"
ConvertNullToDBNull="true">
<SelectParameters>
<asp:SessionParameter DefaultValue="60" Name="registrantId"
SessionField="RegistrantId"
Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asparameter Name="firstName" Type="String" />
<asparameter Name="mI" Type="String" />
<asparameter Name="lastName" Type="String" />
<asparameter Name="eMail" Type="String" />
...

My TypeName has:
public void UpdateRegistrant( RegistrantDetails reg ) {
SqlConnection con = new SqlConnection( connectionString );
SqlCommand cmd = new SqlCommand( "UpdateRegistrant", con );
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add( new SqlParameter( "@FirstName", SqlDbType.NVarChar,
25 ) );
cmd.Parameters["@FirstName"].Value = reg.FirstName == null ? "" :
reg.FirstName;
....

And my DataObjectTypeName has:
public RegistrantDetails(){}
protected string firstName = String.Empty;
public string FirstName
{
get {return firstName;}
set {if (value != null){firstName = value;}}
}
....

Thanks for any clues as to what I must have missed. No exceptions are
generated and debugger shows the set and update methods aren't invoked.

Thanks much.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGFiYmxlcg==?=
Guest
Posts: n/a
 
      04-13-2006
I figured out the problem. A validation control was actually tripping and
keeping the page from updating. For some reason the validation controls don't
display errors or the validation summary in Firefox. But when I tested in IE
I found the error message. I was hoping cross browser support had improved in
ASP.NET v2.0.

"Dabbler" wrote:

> I have a FormView tied to ObjectDataSource that's not updating and am
> wondering what I missed..
>
> <asp:FormView ID="fvRegDetail" runat="server" DefaultMode="Edit"
> DataKeyNames="RegistrantId" DataSourceID="odsRegistrant"
> CssClass="waFormView" >
> <EditItemTemplate>
> ....
> <asp:Button ID="UpdateButton" runat="server" CausesValidation="True"
> CommandName="Update" Text="Update" ValidationGroup="regForm">
> </asp:Button>
>
> <asp:ObjectDataSource ID="odsRegistrant" runat="server"
> TypeName="RegistrantDB" SelectMethod="GetRegistrant"
> UpdateMethod="UpdateRegistrant" DataObjectTypeName="RegistrantDetails"
> ConvertNullToDBNull="true">
> <SelectParameters>
> <asp:SessionParameter DefaultValue="60" Name="registrantId"
> SessionField="RegistrantId"
> Type="Int32" />
> </SelectParameters>
> <UpdateParameters>
> <asparameter Name="firstName" Type="String" />
> <asparameter Name="mI" Type="String" />
> <asparameter Name="lastName" Type="String" />
> <asparameter Name="eMail" Type="String" />
> ...
>
> My TypeName has:
> public void UpdateRegistrant( RegistrantDetails reg ) {
> SqlConnection con = new SqlConnection( connectionString );
> SqlCommand cmd = new SqlCommand( "UpdateRegistrant", con );
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.Parameters.Add( new SqlParameter( "@FirstName", SqlDbType.NVarChar,
> 25 ) );
> cmd.Parameters["@FirstName"].Value = reg.FirstName == null ? "" :
> reg.FirstName;
> ...
>
> And my DataObjectTypeName has:
> public RegistrantDetails(){}
> protected string firstName = String.Empty;
> public string FirstName
> {
> get {return firstName;}
> set {if (value != null){firstName = value;}}
> }
> ...
>
> Thanks for any clues as to what I must have missed. No exceptions are
> generated and debugger shows the set and update methods aren't invoked.
>
> Thanks much.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formview and ObjectDataSource Update method Aamir Ghanchi ASP .Net 3 02-05-2008 01:57 PM
Problem: Usercontrol + Objectdatasource not updating parameters timdelong1@yahoo.com ASP .Net 1 09-24-2007 03:53 PM
formview, objectdatasource, update method kidders ASP .Net 0 01-23-2007 04:42 PM
ObjectDataSource & FormView adding two extra paramaters to Update method giving error non-generic method ... Fred Dag ASP .Net 0 09-18-2006 10:36 PM
FormView not updating MasterChief ASP .Net 1 03-02-2006 01:38 PM



Advertisments