Formview event not handled (???)

J

javelin

Since I haven't had any success manually updating this formview, I
thought I'd repost on another route I'm trying. To recap, I am
manually binding to a datasource using the MySQL .NET connector, and
I've been able to run action queries on this database when directly
coding them. However, I now have the need to update the formview. I've
tried to use the FormView.UpdateItem(), and then a LinkButton control,
and in both cases get a "missing event handler" error. Using the
LinkButton, I get the following:

The FormView 'fvEditImpRec' fired event ItemUpdating which wasn't
handled.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The FormView
'fvEditImpRec' fired event ItemUpdating which wasn't handled.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace
below.


[HttpException (0x80004005): The FormView 'fvEditImpRec' fired event
ItemUpdating which wasn't handled.]

System.Web.UI.WebControls.FormView.OnItemUpdating(FormViewUpdateEventArgs
e) +324
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg,
Boolean causesValidation) +972
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +545
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source,
EventArgs e) +163
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +56
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source,
EventArgs e) +118
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +56
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
+106
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +175

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+242


Please let me know if anyone has a clue for me, as I'm newer to .NET
than VB and classic ASP, so I need direction.

Thanks.
 
T

Teemu Keiski

Hi,

data controls in ASP.NET 2.0, when used through manual databinding just
require yopu top handle certain events, and they inform it this way.
Basically, all you need to do is to attach a handler method for ItemUpdating
event, and that's it.


--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net


javelin said:
Since I haven't had any success manually updating this formview, I
thought I'd repost on another route I'm trying. To recap, I am
manually binding to a datasource using the MySQL .NET connector, and
I've been able to run action queries on this database when directly
coding them. However, I now have the need to update the formview. I've
tried to use the FormView.UpdateItem(), and then a LinkButton control,
and in both cases get a "missing event handler" error. Using the
LinkButton, I get the following:

The FormView 'fvEditImpRec' fired event ItemUpdating which wasn't
handled.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The FormView
'fvEditImpRec' fired event ItemUpdating which wasn't handled.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace
below.


[HttpException (0x80004005): The FormView 'fvEditImpRec' fired event
ItemUpdating which wasn't handled.]

System.Web.UI.WebControls.FormView.OnItemUpdating(FormViewUpdateEventArgs
e) +324
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg,
Boolean causesValidation) +972
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +545
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source,
EventArgs e) +163
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +56
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source,
EventArgs e) +118
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +56
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
+106
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +175

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+242


Please let me know if anyone has a clue for me, as I'm newer to .NET
than VB and classic ASP, so I need direction.

Thanks.
 
J

javelin

I actually did just that, and it did not work. I admit, I don't know
what to put in the ItemUpdating event, nor the required syntax, but I
thought it should at least fire off the event once I created it, and
it doesn't appear to even try. Can you give me a simple example of an
ItemUpdating event function?



Hi,

data controls in ASP.NET 2.0, when used through manual databinding just
require yopu top handle certain events, and they inform it this way.
Basically, all you need to do is to attach a handler method for ItemUpdating
event, and that's it.

--
Teemu Keiski
AspInsider, ASP.NET MVPhttp://blogs.aspadvice.com/jotekehttp://teemukeiski.net


Since I haven't had any success manually updating this formview, I
thought I'd repost on another route I'm trying. To recap, I am
manually binding to a datasource using the MySQL .NET connector, and
I've been able to run action queries on this database when directly
coding them. However, I now have the need to update the formview. I've
tried to use the FormView.UpdateItem(), and then a LinkButton control,
and in both cases get a "missing event handler" error. Using the
LinkButton, I get the following:
The FormView 'fvEditImpRec' fired event ItemUpdating which wasn't
handled.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The FormView
'fvEditImpRec' fired event ItemUpdating which wasn't handled.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace
below.
[HttpException (0x80004005): The FormView 'fvEditImpRec' fired event
ItemUpdating which wasn't handled.]
System.Web.UI.WebControls.FormView.OnItemUpdating(FormViewUpdateEventArgs
e) +324
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg,
Boolean causesValidation) +972
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +545
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source,
EventArgs e) +163
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +56
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source,
EventArgs e) +118
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +56
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
+106
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +175
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+242
Please let me know if anyone has a clue for me, as I'm newer to .NET
than VB and classic ASP, so I need direction.
 
J

javelin

Hi, thanks for your reply. I'm not sure what to do with the
"Employee.UpdateEmployee". Is "Employee" the target table name, or the
dataset object name?


Javelin-

I prefer to use the FormViewCommandEventArgs to read in the commands. I've
never tried it with mySql, but I'm assuming implementation is the same since
it's outside the data layer.

On your form view, just associate your Update, Edit, Cancel, etc buttons
with similar CommandName parameters:

<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />

<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />

Like so... and in your code behind, create an event method for ItemCommand.

protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs
e)
{
if (e.CommandName.Equals("Edit"))
{
FormView1.ChangeMode(FormViewMode.Edit);
}
else if (e.CommandName.Equals("Cancel"))
{
FormView1.ChangeMode(FormViewMode.ReadOnly);
}
else if (e.CommandName.Equals("Update"))
{
int id = Convert.ToInt32(((Label)FormView1.FindControl("IdLabel")).Text);
string name = ((TextBox)FormView1.FindControl("NameTextBox")).Text;
string city = ((TextBox)FormView1.FindControl("CityTextBox")).Text;
string state = ((TextBox)FormView1.FindControl("StateTextBox")).Text;
Employee.UpdateEmployee(id, name, city, state);
}
}

Odd code... was using it for an example in another thread, but same concept...
you could place whatever data logic you need to access your database, pass
update commands, etc. AFAIK, ItemUpdating is an event that fires just prior
to whatever you have specified on the data source object as the UpdateMethod.
If you're manually pushing your data into the FormView, then you probably
don't have that event.

HTH.

-dl

--
David R. Longneckerhttp://blog.tiredstudent.com

j> I actually did just that, and it did not work. I admit, I don't know
j> what to put in the ItemUpdating event, nor the required syntax, but I
j> thought it should at least fire off the event once I created it, and
j> it doesn't appear to even try. Can you give me a simple example of an
j> ItemUpdating event function?
j>
Hi,
data controls in ASP.NET 2.0, when used through manual databinding
just require yopu top handle certain events, and they inform it this
way. Basically, all you need to do is to attach a handler method for
ItemUpdating event, and that's it.
--
Teemu Keiski
AspInsider, ASP.NET
MVPhttp://blogs.aspadvice.com/jotekehttp://teemukeiski.net

Since I haven't had any success manually updating this formview, I
thought I'd repost on another route I'm trying. To recap, I am
manually binding to a datasource using the MySQL .NET connector, and
I've been able to run action queries on this database when directly
coding them. However, I now have the need to update the formview.
I've tried to use the FormView.UpdateItem(), and then a LinkButton
control, and in both cases get a "missing event handler" error.
Using the LinkButton, I get the following:
The FormView 'fvEditImpRec' fired event ItemUpdating which wasn't
handled.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The FormView
'fvEditImpRec' fired event ItemUpdating which wasn't handled.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location
of the exception can be identified using the exception stack trace
below.
[HttpException (0x80004005): The FormView 'fvEditImpRec' fired event
ItemUpdating which wasn't handled.]
System.Web.UI.WebControls.FormView.OnItemUpdating(FormViewUpdateEven
tArgs
e) +324
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg,
Boolean causesValidation) +972
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +545
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source,
EventArgs e) +163
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +56
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source,
EventArgs e) +118
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +56
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
+106
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +175
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHan
dler.RaisePostBackEvent(String
eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+242
Please let me know if anyone has a clue for me, as I'm newer to .NET
than VB and classic ASP, so I need direction.
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top