.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

Clear FormView after Insert or Delete

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net
 

How do I clear my formview after a record has been inserted or deleted? At the moment it just sits in the previous state with the same details in the fields, still with the Insert button. Either it would be good to drop the formview altogether (I have a grid view on the same page) or move into the edit mode for the just inserted record.

Also the same with the delete - the formview stays on screen with the deleted record details and the delete button still available - I know it has fired though as my gridview is updated.

Thanks




View Complete Post


More Related Resource Links

SqlCommand.ExecuteNonQuery() returns -1 when doing Insert / Update / Delete

  
Sometimes you end up with a return value of -1 when using the SqlClient.SqlCommand.ExecuteNonQuery method.

Why is that?



Well, the ExecuteNonQuery method is there for statements for changing data, ie. DELETE / UPDATE /INSERT, and the returned value are the number of rows affected by that statement.

When checking the documentation we can see that there are some conditions that return -1.



For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command.

When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of

rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.

Large volume of INSERT/DELETE

  
 I support the DB for a 3rd party application. Lately users have been complaining about the application being sluggish. Checking into it I found that the vendor decided to write their own locking system (much like peoplesoft does/did). In short, I have a very small table (maxes out at around 3000 rows, 5 columns (int, varchar(30), int, varchar(30), int, int). They store locking records in the table, they are inserted and deleted at a rate of about 10 per sec/600-900 per min. The PK is composite across the columns required to enforce uniqueness. There is no identity column. The IO involved in these inserts and deletes results in enormous amounts of writelog waits. Since the application is built around this custom record locking, and this table is the record of who has what locked, delays on these inserts and deletes translates to delays on everything. I already have plans to address the disk subsystem. In the interim, is there anything I can do to relieve IO this table generates from a design perspective?

formview insert help!!!

  
im using FORM VIEW Control for inserting , i want as i click on insert button of form view control it shows the just inserted data by form view in any GRID VIEW, FORM VIO

Allow or deny roles to update, insert and delete records.

  
Hello, I have two roles "Admin" and "Basic". I also have a listview on the web page. My goal is that to make "Admin" role has the highest privilege to deal with records such as "insert", "update" and "delete". For the role "Basic", it only can update the records. Is there any sample code for that? Thanks.  

Possible to insert & update in formview?

  
I have a formview where DefaultMode="Insert". Underneath, I have a gridview that displays the information from the inserts. Is there a way to update the information as well as insert? Maybe there is a better way to do what I'm trying to do. Any help is appreciated. Thanks!

Possible to update and insert from formview?

  
I have a formview where DefaultMode="Insert". Underneath, I have a gridview that displays the information from the inserts. Is there a way to update the information as well as insert? Maybe there is a better way to do what I'm trying to do. Any help is appreciated. Thanks!

Is this a bug in MERGE statement with DELETE/INSERT?

  
This looks to me like a bug with MERGE statement. This does not work on SQL 2008 and 2008 R2. Note that the first commneted statement works properly but the second does not. Is there any explanation why not, other than a bug? Duplication script below. use tempdb go /* IF object_id('dbo.Test', 'U') IS NOT NULL DROP TABLE dbo.Test go IF object_id('dbo.Src', 'U') IS NOT NULL DROP TABLE dbo.Src go */ IF object_id('dbo.Test', 'U') IS NULL BEGIN     CREATE TABLE dbo.Test     (         intID int NOT NULL IDENTITY PRIMARY KEY         ,sysID int NOT NULL         ,ioID int NOT NULL         ,Code nvarchar(10) NOT NULL     )     INSERT dbo.test (sysID, ioID, Code) VALUES (1, 1, 'A')       CREATE UNIQUE NONCLUSTERED INDEX [UIXF_Test] ON [dbo].[Test]     (           [sysID] ASC,           [ioID] ASC     )     WHERE ([ioID] IN ((1)))     WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON,

Is INSERT = DELETE + INSERT?

  
Does INSERTing a row equivalent to DELETE & INSERT? Please provide more info on this.

Formview check for duplicate value before insert

  
I've looked at some posts on here but I keep getting errors.  I am just trying to see if an email address exists already before the insert and if it does, have a label display that message to the user. From what I read so far, it looks like I could do a query in the ItemInserting event.  I just need help on the code.  Thanks in advance for any help.. Here is the Code Behind.....where I assume I can do the duplicate check in the ItemInserting event... Protected Sub duplicatecheck(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles FormView1.ItemInsertingEnd   End Sub     Here is the formview page...   <%@ Page Language="VB" AutoEventWireup="false" CodeFile="signup.aspx.vb" Inherits="signup" %> <! < <DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">html xmlns="http://www.w3.org/1999/xhtml">head runat="server">   </ <<title></title>head>body>  <form id="form1" runat="server">  <div>      <asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" DataSourceID="SqlDataSource2" Def

Display Inserted Record After Insert Using A FormView

  
How do I display a record in a FormView once the record has been inserted? I'm able to get the Identity of the new record without anyproblems, but I can't figure out how I should code the _ItemCreated event. Protected Sub FormViewMessageDetail_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs) 'Refresh the list to show the new record RepeaterMessages.DataBind() 'Set the .SelectCommand to Select the New Record SqlDataSourceMessageDetail.SelectCommand = "SELECT * FROM Messages WHERE [Id] = " & NewId FormViewMessage.DataBind() FormViewMessage.ChangeMode(FormViewMode.Edit) test.Text = NewId.ToString End Sub Protected Sub SQLDataSourceMessageDetail_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) NewId = e.Command.Parameters("@NewId").Value End Sub

DropDownList inside FormView Insert Template

  
Hi, I am trying to change the textboxes in the FormView insert template to dropdownlists but they keep setting the parameters to null.   Here's what I have:  <asp:DropDownList ID="ddlYearOfQualification" SelectedValue='<%# Bind("YearOfQualification") %>' runat="server"> </asp:DropDownList> In Page_Load CType(frmSurvey.FindControl("ddlYearOfQualification"), DropDownList).Items.Add(New ListItem("2010", "2010"))CType(frmSurvey.FindControl("ddlYearOfQualification"), DropDownList).Items.Add(New ListItem("2009", "2009"))   and in the SqlDataSource InsertCommand="INSERT INTO [tblSurvey] (... [YearOfQualification] ...) VALUES ( ... @YearOfQualification ... ) And in insert parameters: <asp:Parameter Name="YearOfQualification" Type="Int16" /> And the insert fails with YearOfQualification as null. If I sue the standard textbox: <asp:TextBox ID="YearOfQualificationTextBox" runat="server"                 Text='<%# Bind("YearOfQualification") %>' /> It works.   Any ideas? Many thanks in advance.

How To Do An Insert Loop With Two Textboxes In A Formview

  
Hello forum I have a formview (frmExpenses) and it has two textboxes (txtCorporateCost and txtPersonalCost) .  I'm wanting to input their text into tblExpenses, however, in the same column (colExpenses) but different rows.  When txtCorporateCost's amount is inserted I would like for the text "Corporate_Exp" to be inserted in column "colExpenseName" and when txtPersonalCost's amount is inserted I would like for the text "Personal_Exp" to be entered in colExpenseName as well.  How do I go about this? Thank you

Formview: Insert Item Issues

  
Hi, I have a formview for insert and updates. I was trying to call a procedure in formview_itemcommand event without setting InsertMethod for the ObjectDataSource. I got anerror and so I gave the exact procedure name for insert method to get rid of the error. Since the formview objectdatasource method does not exactly match (the no of argument and name) with FormView Datasource(in insertiemtemplate), I was trying to avoid calling the selectmethod defined. I was able to insert the record in itemcommand event.  The problem is 1. While exiting out the Item_command event it gives the following error Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: FormView 'FormViewInsertApplication'                 must be in insert mode to insert a new record.2. After insert, I tried setting the default mode readonly. It does not work How do I by pass the above problems or is there other better way of accomplishing the same. ThanksSuresh Sections of Code----------------------  protected void FormViewInsertApplication_ItemCommand(object sender, FormViewCommandEventArgs e)    {        FormView fvApp = (FormView)FindControl("FormViewInsertApplication");        if (e.Comman

MS Linq To SQL Samples - Insert/Update/Delete

  
Hi, I'm stumbling along trying my hand at Linq to SQL and have come across this code below that was provided by MS.http://msdn.microsoft.com/en-us/vbasic/bb737928.aspxThe problem is there is no ".add" method for Categories to chose in the statement db2.Categories.add(newCategory)I've seen similar videos here on ASP .NET that uses code very much like the example below, but I am unable to run this example connected to a Northwind SQL database using Web Developer 2010 Express. This is the One-to-Many example listed under Linq To SQL Samples - Insert/Update/Delete. Thanks for any help! Shawn Dim db2 = New DataClassesDataContext Dim ds = New DataLoadOptions() ds.LoadWith(Of Category)(Function(p) p.Products) db2.LoadOptions = ds Dim newCategory = New Category With {.CategoryName = "Widgets", _ .Description = "Widgets are the customer-facing analogues " & _ "to sprockets and cogs.", _ .Picture = Nothing} Dim newProduct = New Product With {.ProductName = "Blue Widget", _ .UnitPrice = 34.56#, _ .Category = newCategory, _

Update, delete, insert

  
I have two databases.  When I am using MS Visual Web Developer, I can drag the table onto the webpage and it gives me check boxes to Insert, Update, Delete,... When I do the exact thing using the other database, it only has check boxes forpaging, sorting and selection.  What is the difference?  I seem to have all teh same permissions in both databases. How can I make the second database update, delete and insert?  

Update, Delete, Insert Options

  
I have two databases.  When I am using MS Visual Web Developer, I can drag the table onto the webpage and it gives me check boxes to Insert, Update, Delete,... When I do the exact thing using the other database, it only has check boxes forpaging, sorting and selection.  What is the difference?  I seem to have all teh same permissions in both databases.

FormView Insert

  
I am working to insert into a table with the ASP.NET user ID dynamically.  ASP.NET build-in security is used in my website.In the aspx file (C#), I use FormView and try to do it from <asp:SqlDataSource> in the InsertCommand:"INSERT INTO [Journal] ([jUserName], [jComment]) VALUES (<%# (Context.User.Identity.Name or Profile.xxx) %>, @sjComment,)"I run into problems and I wonder if it is the syntax or does it make sense to do without scope issues?Thanks in advance.-ideesw
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend