How to use FormView 's edit, cancel, insert and delete without using a control (Ex: sqldatasource, objectdatasource, etc..)?

I'm using C#, I cannot find any examples how to use edit, cancel, update, delete feature of the formview without using controls like objectdataSource/sqldataSource?

I have 4 buttons (EDIT, SAVE, CANCEL, Delete), not sure how trigger the edit temple, insert template, etc... I would perfer to do it it programmatically.

I would be grateful for any help! 

 

0
chaumette
4/6/2008 8:41:34 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

4 Replies
1268 Views

Similar Articles

[PageSpeed] 6
Get it on Google Play
Get it on Apple App Store

if oyu want to change the Current Displayed Tempalte for the FormView ,

you can call FormView.ChangeMode as  follows:

 

       ' put the FormView in edit mode 
        FormView1.ChangeMode(FormViewMode.Edit)
        
        ' put the Formview in IsenrtMode 
        FormView1.ChangeMode(FormViewMode.Insert)
        
        ' put the FormView in View (Itemtempalte) mode
        FormView1.ChangeMode(FormViewMode.ReadOnly)
 
Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

0
anas
4/6/2008 10:44:46 PM

Thanks for that info. But how do I get my (update,delete,edit,cancel)  button point to the implementation (BL.Update(), BL.Delete(), etc...) ? I how do I handle their events?

What do I need to add in the gridView and what I need to add in the code behind? 

 

 

0
chaumette
4/6/2008 10:55:30 PM

Why you don't want to use the Objectdatasource ?

the following buttons inside the ItemTemplate will automaticly trigger the corresponding events ..

 

     <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
            Text="Edit">
        </asp:LinkButton>
        <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
            Text="Delete">
        </asp:LinkButton>
        <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
            Text="New">
        </asp:LinkButton>
 

the importan thing is : to set the CommandName for every button ,

so if you want 

  •  cancel button , just set its CommandName "Cancel "
  • Insert Button, set its commandName "Insert"
  • Delete button : set its commandName "Delete"
  • Update Button : set Its CommandName "Update"

setting the correct command name for the button will make it correctly call the corersponding Event ..

for example : if you set the CommandName to Insert , clicking on that button will trigger the Inserting event handler for the FomView , which is call FormView.Insert....

 


Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

0
anas
4/6/2008 11:24:47 PM

Thank you. It was so simple,not sure why I never considered just clicking! I see object datasource used everywhere, but our tech lead wants to avoid using controls to perform the functionality. 

0
chaumette
4/7/2008 1:39:43 PM
Reply:

Similar Artilces:

how to use sqldatasource's advanced option when we are using FormView Control?
dear Please Help me?  i have face a problem when i use the Formview Control in asp.net 2.0. and bind with SqlDataSource, and i use the SqlDataSource's advance sql generation option. it display as disable. what is main reason behind that. and how i remove this problem. Please help me and give proper solution  Guree Hi:   Could you please post a screenshot to elaborate your problem? ThanksSincerely,Allen ChenMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help. I know thi...

Using Data Controls Without Using ObjectDataSource Control
Hi, I've been looking on the Internet for a tutorial that would show me how to use the data conrols (FormView, GridView etc) without using an ObjectDataSource (or any other data source control).  The reason is that I want to use a formview and gridview from within another formview control to create a single form  that would allow me to insert, update and delete an order and its order details at the same time. I thought that this could be achieved by having a DataSet containing two DataTable objects in the code-behind with the Order DataTable containing one row to repres...

What control do I use (or do I not use a control at all...)
Okay so here's the story so far. I am making a blog to be incorporated into a website. Well, I'm doing the blog from scratch. I'm using MySQL to source all the data via MySQL .NET/Connector. Now while developing the script, I used DataReader and Response.Write to show the blog topics. Now that it has come to put it under a design (I'm using a Master Page for that), I've hit the problem. Response.Write shows all the topics before any of the design elements could be incorporated. So that (more or less) is out of question. So next I looked into the data presentation controls. I looked up GridVi...

is it possible to use loginstatus control without using login control?
 Hi friendspls let me clear in this.is it possible to use loginstatus control without using login control?thanks in advance          Yes, if you write your own login control that plugs in using asp.net authentication via the provider model then the login status will still work fine.You can set up custom providers in web.config.  thanks to reply. can u give me a sample code?  Yeah for custom providers in web.config its pretty simple, but the rolling your own is a complex task. Do you already have a database or some reason for...

Editing and Inserting using a formview Control
Well, I followed all the Microsoft steps in the Walkthrough for using a formview control.  When I was doing simple edits and updates, the control worked fine.  When I added code to 1) Hide the formview control on page load; 2)Set the dropdown box that controls what you see in the formview to equal the formview value when editing is complete; and 3) Add/Remove an initial value in the dropdown box a few strange things happened. 1. The dropdown box contains not 1, but 2 intial values of "(Select)".  Here's the code: Protected Sub DropDownList1_DataBound(ByVa...

Is there a textbox control that does NOT use the 'size=1, size4' etc. archaic form of html? But uses more modern css?
Hey folks.  After showing the site to a number of writers, they're very happy w/the features of DNN, but not at all w/the Text/HTML module, since obviously, how they're writing *looks* is sort of important to them, and the granularity of FTB, and the size=1, etc...is just not gonna do it.  I know there's a discussion *somewhere* on other editors, but when I do a search, I get like 20 pages of stuff to wade through, and after spending 30 minutes reading, I never see a mention of this feature, which is of critical importance to writers. Is there a TextBox that allows use o...

How to detect if the 'cancel' button on Acrobat Reader's PDF print dialog window has been clicked when using Acrobat Reader ActiveX control in Powerbuilder 9
Product name: Acrobat Reader V5.0, Powerbuilder V9 Operating System: Windows XP I have an Acrobat Reader's ActiveX control on my window application to present and print PDF files. The application was developed using Powerbuilder V9. I need to know if a user has just printed a file then save the printed date into a database. The user can click the 'Cancel' button on the print dialog window from Acrobat Reader to cancel the printing. In this case I won't update the printed date. How can I know if the user has clicked the 'Cancel' button to cancel the printing? ...

What kind of benefits are there to use ObjectDataSource control instead of SqlDataSource control?
I have learned some Starter Kits such as Personal WebSite Starter Kit, Classifieds Site..., I find these programs always use ObjectDataSource control as the datasource of DataList, GridView and write down many additional codes. I think that it will be simple if use SqlDataSource control.I can write some Stored Procedures with parameters in SQL 2005 database and select StoredProcedure from SelectCommandType in SqlDataSource control, so I think I can do the same work either ObjectDataSource control or SqlDataSource control if I only handle SQL 2005 database. I know ObjectDataSource can handle...

How to use WebPartZone control in gridview control's template?
I Need Your Help To Solve The Following Problem.Thanks. I want to use WebPartZone control (NOT ATLAS) like this:         <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">            <Columns>                <asp:TemplateField HeaderText="templatecol">                    <ItemT...

I am trying to use a multiview control but it won't let me use any controls within it???
Error Creating control 1- Multiview 1 Multiview cannot have children of type form view. It can only have children of form view.   What exactly is a form view?  What controls can I use in a multiview?  I tried a label, datagrid, details view, form view, textbox and I get the same error with all controls. This cant be right?  I must be doing something wrong. Sorry to sound such a newbie but I haven't got my ASP.Net book in the mail yet.     Thanks hi boy,<asp:MultiView ID="myView" runat="server" ActiveViewIndex="...

Issue with getting values from child controls in a gridview, to use for the update using a SQLDataSource control
Hi all, I have a gridview bound with a SQLDataSource. I am using the Update feature of the SQLDataSource to update a SQL Server database with values entered into the gridview. However I am not getting it to work. I believe this is due to the controls that contain the user entries are not the gridview itself, but rather child controls within the gridview. I have been using the names of the actual controls but nothing happens. Upon submit, the screen returns blank, and the database is not updated. Here is some code:   <asp:GridView ID="GridEditSettlement" runat="server" AutoGenerate...

''null' or not an object' error using validation controls in user control
Wonder if anybody has come across this before.I’m using Atlas together with some user controls I’ve created for user input that has validation controls on the forms.  If I remove the validation controls then all works fine… however once they are enabled I get a very annoying javascript error saying “ ‘null’ is null or not an object “ Where do I even start debugging this? If somebody knows what im doing wrong or how I could fix this please let me know.   Thanks ...

reference control's value when I used a repeater to create controls???
Hi I am using a "repeater" to dynamicly create controls on my aspx page. I pull server names out of a table and display them on the web page as labels--virtically. And after each lable, I have a listbox and a textbox follow it. On the web form page, it looks like this---if for example i have 3 servers: serverName1(label) status(listbox) comments(textbox) serverName2(label) status(listbox) comments(textbox) serverName3(label) status(listbox) comments(textbox) What I want to do is that after user pick the status for each server name and add comments for it...

using an upload control in a datagrid or a dataview using the edit and or insert templates.
I figured this out and wanted to share how to use an upload control in a datagrid or a dataview  and use the built in edit and insert templates to add the updated file to the record.  I also included the new record page.  This page uploads a file in a formview and redirects the page back to the gridview.  finding the controls in a gridview is different than finding them in a formsview.  So I include both pages.  I am using vs2005 and .net 2.0  and an older version of SQL There are other comments on the internet about using an upload control to s...

Web resources about - How to use FormView 's edit, cancel, insert and delete without using a control (Ex: sqldatasource, objectdatasource, etc..)? - asp.net.presentation-controls

Forums Forums Database Error
This is a discussion forum powered by vBulletin. To find out about vBulletin, go to http://www.vbulletin.com/ .

Using The LINQDataSource
-*+There is a new datasource control available in Visual Studio that works in much the same way as the SQLDataSource and the ObjectDataSource. ...

ASP.NET Web Forms DynamicData FieldTemplates for DbGeography Spatial Types
... a FormView in ASP.NET Web Forms. Notice the ItemType is set, rather than using Eval(). We're also using SelectMethod rather than an ObjectDataSource. ...

LINQ Tutorials : LINQ Tutorials, Articles and Resources
Articles and Helpful Tutorials for LINQ and ASP.NET

About Mikesdotnetting
I started this site as somewhere to store answers to bits and pieces that I see asked frequently in the forums at www.asp.net . Rather than type ...

Runnable code for JQuery, Codeigniter, NodeJS, PHP, Python and more - Runnable
Runnable code for dart-vm, express, paypal, google, evernote, everyauth, ejs, rendr, CakePHP, php-mysql, php-facebook, codeigniter, imagemagick, ...

ASP.NET Pivot Table - RadPivotGrid for ASP.NET AJAX
... of all data reports. Try now! Use any declarative data source control (AccessDataSource, SqlDataSource, LinqDataSource, EntityDataSource, ObjectDataSource, ...

Miscellaneous « AJ\’s blog
AJ\’s blog January 28, 2012 2011 in review Filed under: Miscellaneous — ajdotnet @ 7:41 pm The WordPress.com stats helper monkeys prepared a ...

ObjectDataSource - Selectcount method with custom parameters and custom paging.
protected void obds_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { if (!e.ExecutingSelectCount) { e.InputParameters["filter"] ...

Archive
Archive - Forever Breathes The Lonely Word

Resources last updated: 1/19/2016 9:56:45 PM