Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Controls / April 2006

Tip: Looking for answers? Try searching our database.

FormView events

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TheDeacon - 21 Apr 2006 14:45 GMT
Is there a way to use the FormView for Selects, but let it post back
for Inserts and Updates?
The problem I am running up against is that, if you use an SQL
DataSource for the Formview, and you only speicify a SELECT command in
the SQLDataSource, you get an error when you click the "Insert" link.

Is there a way to tell it to NOT look for an INSERT command in the
datasource, but just postback the data to the server and let the
code-behind handle it?

Thanks,
David
TheDeacon - 27 Apr 2006 18:24 GMT
Since no one answered me, it has taken me a while to get the answer.
Basically, what to do, if you want to use a FormView for its Select
capabilities, or for its Insert Capabilies, but not use the Update,
say, or Delete, is to make use of the corresponding event in the SQL
Datasource control OR the Formview Control (SqlDataSource1_Updating,
for example) and then use the "e" argument to cancel the event: But
before you cancel, you can do what you want with the information held
in the FormView's controls.
So, to cancel an Updating event:
protected void SqlDataSource1_Inserting(object sender,
SqlDataSourceCommandEventArgs e)
       {
          e.Cancel = true;
       }
You can also do this on a GridView. After the Cancel the control might
need some adjusting, such as a DataBind, or setting the Mode back to
ReadOnly, or whatever.

David

>Is there a way to use the FormView for Selects, but let it post back
>for Inserts and Updates?
[quoted text clipped - 8 lines]
>Thanks,
>David

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.