MVC3 Deleting A Record Using A Sub-form

Feb 1, 2011

I am trying to delete a record being displayed in a table on my ManageUser view using a sub-form, thus

<table cellpadding="2" cellspacing="0" border="1" summary="User Grid" style="text-align: left">
<tr style="background-color: #ABC3CB;">
<th align="center">User Name</th>
<th align="center">Approved</th>.....

but instead, it is returning directly to the Admin/ManagerUser view, thus displaying my original set of records again.

View 1 Replies


Similar Messages:

MVC :: Deleting Record

Mar 24, 2010

I've followed a blog here on removing a record. this is what I have. everything works except the page doesn't refresh after delete has been called as if it's doing it in AJAX. I only see the change when i do a manual page refresh. [URL]

Master Page Head section

<head runat="server">
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script>
</head>

Index View:

<% foreach (var item in Model) { %>
<tr>
<d>
<%= Html.ActionLink("Edit", "Edit", new { id = item.LogId })%> |
<%= Html.ActionLink("Details", "Details", new { id=item.LogId })%> |
<a href="/Log/Delete/<%= item.LogId %>" onclick="$.post(this.href); return false;">Delete</a>
</td>
<td>
<%= Html.Encode(item.CampaignId) %>
</td>

Controller:
//DELETE
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Delete(int id)
{
try
{
_repository.Remove(id);
return RedirectToAction("Index");
}
catch
{
return View();
}
}

View 4 Replies

Web Forms :: Refreshing Grid After Deleting A Record?

Sep 30, 2010

I have a form that when I click the delete button I want it to refresh the grid with that record removed from the grid. Does anyone know how to do this. Is this something handled in the code behind? Here is my code for the delete button on the design page:

[Code]....

View 17 Replies

Add A Confirmation Dialogue Window Before Deleting The Record

Mar 14, 2010

I have a dropdown list, and can select names to delete from db table user.

Just want to add a confirmation dialogue window before deleting the record.

I am using a simple function at js to confirm. Isn't that enough to go to btnDelete_click() if true? I am using LINQ to SQL.

I tried:

(code behind)

protected void Page_Load (object
sender, EventArgs e)
{
if(!IsPostBack)
btnDelete.Attributes.Add("onclick","return check();");
}......

View 6 Replies

Web Forms :: Confirmation Dialog Box Before Deleting A Record

Jun 4, 2012

I want to confirm from the user before deleting a record. I want to show a message box to confirm operation... How I do that.. I used query to delete a record on button's click event..

View 1 Replies

MVC :: After Deleting The Record Successfully At The End It Is Not Refreshing The Page Properly?

Jun 13, 2010

has someone make ajax.actionlink for delete to work properly.After deleting the record successfully at the end it is not refreshing the page properly.the page refresh is my problem. i have defined the updatetarget id and returning view(model) from my controller but it is returning the master page with it.So the thing is that i am having a page with a page.I have used redirect as well which is not refreshing,

[Code]....

abc is the id of the table From controller

View("ManageGroup,Model);

View 1 Replies

Display Confirmation Message Before Deleting A Record From Database

Dec 12, 2012

I have a web in asp.net+vb code and sql database

Protected Sub movebtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles movebtn.Click
Dim con As New SqlConnection
con.ConnectionString = ConfigurationManager.ConnectionStrings("26ConnectionString").ConnectionString
con.Open()
If persno.Text = "" Then
Page.ClientScript.RegisterStartupScript(Me.GetType, "Forms", "<script> alert('Enter Pers No of Offr ..........') </script>")

[Code] ....

I want to add a confirmation before deleting the data and popup message box...

View 1 Replies

Web Forms :: Display Confirm Dialog Box Before Deleting A Record

Jan 11, 2013

I am using gridview,in that gridview i provide a link button as delete,if the user click the delete button,it will deleted properly no problem in my code,before delete i want to show an dialog box like, are you want to delete the employee details,,how can i do this in my code..

Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles GridView1.RowCommand
If (e.CommandName = "DELETE_Employeeid") Then
'Delete button is clicked
Dim empid = e.CommandArgument.ToString()

[Code] ....

View 1 Replies

Forms Data Controls :: Deleting A Record In Gridview Using A SQLDataSource?

Feb 6, 2010

I have a gridview and a SQLDataSource control. In my gridview I have 2 commandfields "Edit" and "Delete"

The "Edit" command field works as expected. Using the "Delete" command field I get the error below.

Server Error in '/DataControls' Application.

The DELETE statement conflicted with the REFERENCE constraint "FK__titleauth__au_id__0CBAE877". The conflict occurred in database "pubs", table "dbo.titleauthor", column 'au_id'. The statement has been terminated.

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.Data.SqlClient.SqlException: The DELETE statement conflicted with the REFERENCE constraint "FK__titleauth__au_id__0CBAE877". The conflict occurred in database "pubs", table "dbo.titleauthor", column 'au_id'. The statement has been terminated.

Source Error:
[Code]....

Stack Trace:

[Code]....

View 1 Replies

Forms Data Controls :: Gridview Not Refreshing After Deleting Record?

Nov 27, 2010

I am using a Gridview inside an UpdatePanel. I am using the RowCommand method to call my code to delete the record. The gridview is bound to a <list> collection. I am unable to get the Gridview to postback / refresh after the users deletes a record; however, if I refresh the page in the browser and the page loads, it obviously is gone. I have searched quite a bit on this where others are having problems but nothing they did work for me, so I was hoping someone could review my code and let me know what I am doing wrong.

Here is my ASPX:

[Code]....

Here is my C#

[Code]....

When I step through the code, the postback happens and then my delete code is called, so once the delete code happens, the page is already finished loading, which seems to be my problem.

View 2 Replies

SQL Server :: Best Method Of Automatically Deleting A Record In A Foreign Table?

Jul 13, 2010

I have two tables with one common field. The field is the primary key in one table, and just a plain field in another. When I delete a record in the table where the common field is the primary key, I want to automaticaly delete a record in the other table that has the same data in the common field.

What is the most effecient method of doign this..triggers?

View 4 Replies

Security :: How To Enable Dual Authentication (Windows And Form) In MVC3

Feb 12, 2011

I am developint an Asp.Net MVC3 web application, which will be available over intranet and internet for users.

For this sake I want to use dual authentication (Forms and Windows). Both authentications works perfectly separately.

Kindly let me know how can I enable both authentications for my single MVC3 site. Windows authentication for Intranet and Form based authentication for Internet user.Looking for your kind cooperation.

View 1 Replies

Forms Data Controls :: Deleting / Updating Record From SQL Database Via GridView

May 11, 2010

I've been googling for 2 days for the solution, but I couldn't find something useful. The problem is that I have GridView that is connected to the SQL database and that is how it is being populated. I added EDIT and DELETE buttons in the columns, but as far as I can see the event which handles them is empty.

[Code]....

View 11 Replies

DataSource Controls :: Deleting All Child Record On The Base Of Primary Key And Foreign Key?

Apr 20, 2010

how can i retrieve the all foreign keys against a single primary key. i mean to say that if a table contain a primary key then it becomes as foreign keys in which tables.

i want to take that nam of that tables and on the base of that tables then i am to delete from all the entries. e.g: if a primary key's column entry deleted then all foreing key entries should also be deleted.

there are 988 tables in a single database. it can't be possible to go for each table to setup foreign key to ON DELETE CASCADE.

.can it have any way to delete against foreign key priority wise? mean to say that parent table contain primary key, child table contain foreign key , now there is another child table which dependent previous child table. then how can i delete all record against it?

i want to do it from programatically. i am using sql server 2005

i have completed this till to that , it retrieves all foreign keys but how to delete now on the base of priority.

[Code]....

View 1 Replies

Forms Data Controls :: Change Gridview Page Upon Inserting / Deleting Record?

Jun 22, 2010

I am having trouble changing page numbers on my gridview after deleting a record if the deletion of the record causes there to be no more records on that page. Currently I have a form below the gridview that adds a record to the datasource of the gridview.

[Code]....

Code behind stuff:

[Code]....

Now with this code above, if I insert a new record using the form below the gridview, it will reload and go to the new page if the insertion causes the record to appear on a new page, however when I delete that record, thus causing nothing to be on that page, the gridview visually just dissappears. I've got the gridview bound by a linqdatasource control, and on the page_load function I only databind if the page is not a postback.

View 2 Replies

Forms Data Controls :: Decrement Gridview RowCount When Deleting Record From Inner GridView?

Apr 22, 2010

Using vb.net/asp.net 2005.I have an inner gridview.The outer gridview is "Authors" and in the inner gridview (GridView1 below) I have to set it up so that the user cannot delete the last book from the inner grid, if they try to delete the last book from that inner grid then I want to show the exception message below.

So I am checking the GridViewRows1.Rows.Count which works great when I have one record (one book) to start with. The problem is when I have 2 books (for example). I am writing out the test statement below and the RowCount is always 2 each time, never decremented, even after I rebind.Editing this now: i realize that my initial logic is faulty because when I rebind my inner gridview I am not specifying which inner gridview so the result is that only the last inner gridview is being re-bound, so I think that I need to get the selected inner gridview and then refresh that...

[Code]....

View 1 Replies

Forms Data Controls :: Deleting A Record On A File With Multiple Keys / Access The Rest Of The Keys?

Feb 8, 2010

I have a DataGrid that I need to be able to use to delete records form a file

[Code]....

[Code]....

I use

((TextBox)GridMenuOptions.Rows[e.RowIndex].Cells[1].Controls[0]).Text;

To access the data in the Grid for updating, but it doesn't work for deleting

I can use

string id = GridMenuOptions.DataKeys[e.RowIndex].Value.ToString();

but that only returns the first key.

How do I access the rest of the keys?

View 9 Replies

DataSource Controls :: Deleting Formatted Record Returns "Input String Was Not In Correct Format"

Oct 19, 2010

I have a bound data field, a detailsview, one of the records I have formatted to currency in the item template. Yet when I go to delete a record, I get a error message "Input string was not in correct format". Take away the formatting and the page runs fine. I tried changing the datatype from int to money, it makes no difference.

View 3 Replies

C# - Deleting From Repeater Item - Erroneous Deleting?

Sep 27, 2010

I have a repeater which binds a set of data. Within this repeater is a column with various controls for updating, deleting, etc. These are image buttons which fire an onclick event such as "DeleteRecord". All this does is fire a stored procedure, passing in the ID of the record to delete from the CommandArgument of the object.

This works wonderfully... except for one rather huge problem. Once you delete a record, if you refresh the page, the record where the first deleted record used to be gets deleted. For instance... if I have 4 records

1 Record1
2 Record2
3 Record3
4 Record4

and I delete record 2... The page reloads with (which is fine):

1 Record1
3 Record3
4 Record4

...if I then hit refresh...

1 Record1
4 Record4

I assume this is because the erroneously deleted object (record3) is now in the same hierarchical place as the old object used to be and .net therefore doesn't know the difference, the page refreshes and fires the onlick event, grabbing out the command argument of the new object and deletes based on the ID as obtained from the commandargument of the new object. This is obviously a huge problem, if a client did this it would destroy data erroneously and I'm at a loss here. Is there any way to stop this from happening? I'm not sure if there is a better way to go about doing things or not. If there isn't, I need some sort of way to tell the page not to execute the event or to cross reference the ID of the object that is intended for deletion against the object itself...

Code below for convenience...

EDIT Wrapped a LinkButton around it because I have some jquery code in here as well which stops the page execution to wait for user confirmation. Pressing "ok" continues page execution.

<asp:LinkButton ID="oDeleteLink" CssClass="oDeleteIcon" CommandName="Delete" CommandArgument='<%# Eval("iAccountID") %>' runat="server">
<asp:ImageButton ImageUrl="/files/system/icons/trash-steel-16.png" ToolTip="Delete This Account" AlternateText="Delete" ID="oDeleteIcon" runat="server" />
</asp:LinkButton>
protected void oAccounts_ItemCommand(Object Sender, RepeaterCommandEventArgs e) {
if (e.CommandName == "Delete") {
int ID = e.CommandArgument.ToString().Numeric();
db.SPs.SpDeleteAccount(ID).Execute();
UI.Confirm(uiBroadcast, "Account has been deleted", "300px");
BindAccounts();
}
}

View 2 Replies

Web Forms :: How To Move To Another Record In The Form View Programmatically

Apr 15, 2010

I want to create jump button to go to the x number of the next record in the form viewWhat is the command in the csharp?

View 2 Replies

VS 2005 How To Edit/update/delete Record On The Form View

Jan 4, 2010

Can someone tell me how to edit/update/delete record on the Form View?

i got this on my Update COMMAND :

Code:

[code]....

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?, Name = ?, Addr1 = ?, Addr2 = ?, Addr3 = ?, Addr4 = ?, PhoneNo = ?, HPhoneNo =' at line 1

View 14 Replies

Web Forms :: How To Save Both Parent And Child Record When Form Submitted

May 27, 2010

I have a webform (parent) with embedded webgrid(child) which uses sqldatasource. What I wanted to accomplish is to save both the form data and the grid data when the Save button is clicked. I tried to save form data(parent) in sqldatasource1_inserting event, does not work. I think there should be a way to do it, just do not know how.

View 4 Replies

MVC :: ClientValidationEnabled Bug In MVC3?

Feb 9, 2011

When I have this in my web.config then everything works as expected:

<appSettings> <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled"value="true"/> </appSettings>
The client validation runs.

However if I turn off the second one, unobtrusive, I would still expect that client validation would work. However it seems to me that it still posts back fully to the server instead of client side validation only. Is this a bug in MVC3?

View 2 Replies

Forms Data Controls :: Getting First Record In Nextpage And Last Record Of Previous Page Of Gridview?

Nov 16, 2010

I am using paging to my gridview (pagesize=4) . now i am in (X) page and i want to get (X+1) page top record or (X-1)page bottom record , how i can get .

View 2 Replies

Forms Data Controls :: Pop Up To Show When No Record Is Selected And Tell The User To First Select A Record?

Mar 21, 2011

I have a delete button bellow my gridview and I want a pop up to show when no record is selected and tell the user to first select a record. The button click event would show the pop up, but my gridview data blanks out.

Here is my code:

[Code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved