[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Using stored procedures with FormView

Posted on 2009-04-24
Medium Priority
Last Modified: 2013-12-17
Greetings all

I am using a FormView to capture various pieces of data. For the updating/inserting I want tosuse stored procedures instead of setting the CommandName to Insert or Edit.

As far as I understand it, I enter the COmmandName for the appropriate buttons and then set up the method as follwos (see snippet).

Is this correct?

In advance, thanks!!

<asp:Button ID="btnInsertC" runat="Server" Text="Insert" CssClass="buttonsOnCollapseHeader"  />
        <asp:Button ID="btnEditC"   runat="Server" Text="Edit" CssClass="buttonsOnCollapseHeader" />
        <asp:Button ID="btnCancel"  runat="Server" Text="Cancel" CssClass="buttonsOnCollapseHeader" />
protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
if (e.CommandName == "New")
  if (e.CommandName == "Edit")

Open in new window

Question by:allanmark
  • 2

Expert Comment

ID: 24227954
no this is not correct.

You have to configure the FormVIew controls, Select, Delete, and Update functions by pointing them to the corresponding data source.

The steps to setup such an environment would be:

1) Drag drop a datasource, connectit to the corresponding Database hosting the stored proceudres you want (Use the server explorer)

2) Drag drop the FormView to your page. Right click the form view for options. Configure your Select, Update and Delete methods by pointing them to the corresponding SPs in your database in the configured datasource

Now the FormView will create select, insert and delete functions in your project, which you can further finetune to your needs.

Please let me know if anything is unclear.

Author Comment

ID: 24228151

A couple of things ...

1.  The DataSource is a DataTable, passed across to the UI, from a DataAccess Layer (eventually we
     will  convert to using Lists, but for now DataTables).
2.  We are also coding in Source view, as opposed to using the Designer.
3.  The procedure has several parameters (excluding the edited fields)

Can I still follow the process of your steps?


Accepted Solution

Kalpana_Natarajan earned 1000 total points
ID: 24228836
SUre you can

Just because you are using a wizard, it does not rob the oppportunity to fine tune.

The wizard cna easily hook up your FormView/Any presentation view control in ASP.NEt to a SQL server and procedure.

However if you want it to make the datasource as a C# data object, then you would have to point the datasource to the C# assembly which has those objects. IN the C# assembly write four methods, which will perform select, insert, update and delete and point the Form View methods to those methods.

Hope this is clear.

I am not at my computer, so am not able to give oyu an exact walkthrough of the process. The wizards options are easy to understand once you open them.


Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question