Forms Data Controls :: Have A Grid Contol That Allows Delete What Would Like To Have Is Someway To Say Are You Sure You Want To Delete?

Feb 8, 2010

I have a grid contol that allows delete what I would like to have is someway to say Are you sure you want to delete?I found this code online, and tried it but it did not work, Do I need something more some behind code maybe?Here is what I found online:Adding 'Delete Protection' to controls If you use a control set up to allow Delete, the Delete button gives a straight delete without any warning, which can be dangerous.To give a warning dialog box, add an OnClientClick event to the Delete button, as follows.

runat="server" CausesValidation="False"
OnClientClick="return confirm('Are you sure you want to delete this record?');"

Here is my code: You can see where I added the code from above.

ID:<asp:label id="IDLabel" runat="server" Text='<%# Eval("ID") %>' /><br />
Name:<asp:label id="NameLabel" runat="server" Text='<%# Bind("Name") %>' /><br />
Destination:<asp:label id="DestinationLabel" runat="server" Text='<%# Bind("Destination") %>' /><br />
OutDate:<asp:label id="OutDateLabel" runat="server" Text='<%# Bind("OutDate") %>' /><br />
ReturnDate:<asp:label id="ReturnDateLabel" runat="server" Text='<%# Bind("ReturnDate") %>' /><br />
LeaveTime:<asp:label id="LeaveTimeLabel" runat="server" Text='<%# Bind("LeaveTime") %>' /><br />
ReturnTime:<asp:label id="ReturnTimeLabel" runat="server" Text='<%# Bind("ReturnTime") %>' /><br />
ContactNumber:<asp:label id="ContactNumberLabel" runat="server" Text='<%# Bind("ContactNumber") %>' />
<asp:linkbutton id="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
<asp:linkbutton id="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete this record?');" Text="Delete" />
<asp:linkbutton id="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New" />

View 23 Replies

Similar Messages:

Forms Data Controls :: Delete Confirmation Box In Gridview With Edit And Delete Buttons?

Nov 18, 2010

How do I reference the delete button to add the delete confirmation box when I have both the Edit and Delete buttons as the last two columns in the Gridview control. The following code works fine without any issues when I have the delete button only:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType != DataControlRowType.DataRow) return;
int lastCellIndex = e.Row.Cells.Count - 1;
Button db = (Button)e.Row.Cells[lastCellIndex].Controls[0];
db.OnClientClick = "if (!window.confirm('Are you sure you want to delete this record?')) return false;";

But, when I have both the Edit and the Delete buttons, I get the following error when I click the edit button while the delete button works fine.

Specified argument was out of the range of valid values. Parameter name: index

How do I reference the delete button so the edit button is not affected in this case?

View 4 Replies

Forms Data Controls :: Delete Images From Folder Using Gridview Delete Link?

Feb 3, 2010

Using "Enable Delete" from Gridview control, I can delete (besides, update, sort, paging, etc) data from the database (this is done automatically). However, how can I delete the actual image that resides in my image folder (i.e. from "pix" folder )? What is the best way to delete image? If using code behind, how? Please write a full code for me. Here is my source code.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="photoID"

View 12 Replies

Forms Data Controls :: How To Insert Delete Confirmation Dialog To Gridview Delete Button

Apr 6, 2010

I am using Sharepoint Designer and trying to insert a Delete button into a gridview. I added this to the top of my ASPX:

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>

and I added this as a Gridview column:


and this is the error I get:

An error occurred during the processing of . System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'SharePoint:DeleteItemButton' is of type 'Microsoft.SharePoint.WebControls.DeleteItemButton'.

View 4 Replies

Forms Data Controls :: Created A ListView And Attempted To Delete A Record Using The Delete Button And Native Procedures?

Sep 14, 2010

I created a ListView and attempted to delete a record using the delete button and native procedures. It failed and threw an error.Pass in a valid dictionary for delete or change your mode to OverwriteChangesIn researching this issue, it appeared there is a problem with the list view when deleteing and
ConflictDetection is set to










View 1 Replies

Forms Data Controls :: Hide Or Delete Row From Grid View?

May 8, 2010

I have following gridview and am filling values through c #.


now i want to hide the row (where u click in "HIDE" <Button Field>) in c # code

protected void GridView1_SelectedIndexChanged(object sender, GridViewDeleteEventArgs e)

View 12 Replies

Forms Data Controls :: Delete Multiple Rows In Grid?

Jun 16, 2010

ihave grid in which i want to delete selected rows (checkbox selected)

i have written code as follow but on click on delete button it delete all.


View 8 Replies

Forms Data Controls :: Delete Row Per Row Basis In Grid View?

Oct 2, 2010

I found this code and tried to implement it in my project. But before running, I got few question. What I want to do is able to delete 1 row each time I click on a button or link.

1. Where is the firing event comes from?

2. Do I need to add a button or link each row (another column)?

3. How does the following code works?


View 2 Replies

Forms Data Controls :: Using A UserControl As The Delete Button On Grid?

Apr 1, 2010

Is it possible to use a usercontrol as the delete button on the gridview?I have got the following line of code going ok for the top line of the grid, but for the 2nd onwards, it tells me i cant have a 'Duplicate Component Name'


View 3 Replies

Forms Data Controls :: Have A Grid View With Some Coulmns Like Name,Phone No Etc With Edit,Delete Column In Grid View?

May 27, 2010

i have a grid view with some coulmns like Name,Phone no etc with Edit,Delete column in grid view. I click a row in grid view to Edit,it goes another page where i can edit all fields .Once i update i redirect the page to gridview. I want the grid view to remain in that particular page say 4 of the grid view

View 5 Replies

Data Controls :: Delete With Confirmation Using Details View Delete Command Button

Nov 7, 2011

I am interested in building an intranet document management system to be used from Internet Explorer using,, and MS SQL Server but have no experience in doing a project like this. Supported file types would be txt, pdf (from scanner or imported from file system), or jpg. What concepts I should look at researching/learning about to build the system in a way that files will be stored as small as possible, retrieved and displayed quickly, and secured. The users would be spread out over a regional area covering 4 states.

View 5 Replies

Data Controls :: Delete With Confirmation Using DetailsView Delete Command Button

Jan 7, 2014

I want to make an conformation dialog on auto generated delete button in detail view that when user press delete dialog or conformation box appear that u sure u want to delete how can i do this? 

View 1 Replies

Forms Data Controls :: How To Make A Custom Grid / Insert / Edit / Delete Page

Jul 9, 2010

Lets say that i want to make a ADMIN page for articles.

1) I show all my articles on lines
2) Each article has an EDIT BUTTON and INSERT NEW button
3) When I click on the EDIT BUTTON, it opens a CUSTOM page where i can Edit my article.
4) When i click on the INSERT NEW BUTTON it opens the same CUSTOM page where i can Insert my article.

I was trying to do it with Gridview and Formsview.

View 8 Replies

Forms Data Controls :: Dynamic Delete LinkButton In ListView Error "Delete Can Only Be Called On A Valid Data Item"

Feb 22, 2010

I need you assistance, Dynamic Delete LinkButton with CommandName=Delete gives me an error: Delete can only be called on a valid data item. nfact I am designing a Complex Grid using .Net 3.5 ListView Control with Scrollbar and Fixed Toolbar: This grid consist of 3 Tables:

1- footer
2- Toolbar Control
3- Scrolling Data Grid with Header

ListView give us only one ItemPlaceHolder to Bind Data as per LayoutTemplate, so I cannot able to manupulate my Toolbar Controls with ItemTemplate :(, therefore I decide to use ItemDataBound to add ImageButtons Dynamically using Init Page Event and I am able to get the result as you saw above:

ImageButton with funnel icon is with CommandName="Filter"
ImageButton with magnifier icon is with CommandName="View"
ImageButton with stop icon is with CommandName="Delete"

Now I can able to handle Filter and View with OnItemCommand Event but when I click Delete button I am getting an error as shown below: The grid used CSS I am sending you the HTML and code behind to resolved this problem: HTML CODE:




View 5 Replies

Forms Data Controls :: DetailsView Delete Method Passing Null Values To Objectdatasource Underlying Object Delete Method

Apr 12, 2010

I am using VS 2008 SP1. My also have included CSS Friendly adapter [URL] in my project ( I mentioned this because my GridView Empty data template is not showing when using GridView's CCS Friendly adapter). I have a GridView and a DetailsView. When a record in GridView is selected its details information is shown in the Details View. Type of Data source I am using is ObjectDataSource. My Insert and Update methods works perfectly. It is only the Delete method that is passing null values to the underlying object delete method. My source codes for both the UI, BLL, DAL is shown below


My Business Object code is below :


My Data Access Layer Code is:


View 2 Replies

Forms Data Controls :: Delete, Edit, Select Items Is In Grid View I Have To Do In C# Code It Will Reflect To Database Also?

May 20, 2010

I want delete, edit, select items is in grid view i have to do in c# code it will reflect to database also

View 3 Replies

Forms Data Controls :: Cannot Delete Data - How To Delete Data In A Table

Jul 18, 2010

check this link: [URL]

Can not delete data. How do I delete data in a table?

View 3 Replies

C# - Delete A Record In Data Grid View?

Mar 21, 2011

I have added a data grid view in Asp page, data is retrieved from the sqlserver2005 and its showing in data grid view, even i have made the auto-generate-delete as TRUE in the properties but when i run the page and click on delete button its showing error.

View 1 Replies

Dynamic Data: Display Edit, Delete And Details At The End Of The Grid?

Jan 26, 2010

I implemented Dynamic Data Website and I would like to display edit, delete and Details columns at the end of the Grid. Please let me know how to do this.

View 1 Replies

Web Forms :: GridView Delete Parameter Doesn't Delete Record

Jan 27, 2011

I have a gridview with edit and delete parameters enabled. When I click on the edit link, I can edit the record successfully. However when I click on the delete link, nothing happens (the record does not get deleted).

View 5 Replies

Web Forms :: Delete Multiple Report In Grid View

Sep 6, 2010

i want to delete multiple report in grid view and i am facing some problems, i am using this Code.

protected void LinkButton1_Click(object sender, EventArgs e)
foreach (GridViewRow row in GridView1.Rows)
CheckBox cb = (CheckBox)row.FindControl("chkSelect");
if (cb.Checked)
int rid = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
SqlDataSource1.DeleteParameters["id"].DefaultValue = rid.ToString();

View 5 Replies

Web Forms :: Validate A Control On A Grid And Delete Button?

Sep 14, 2010

I have a grid with checkboxes on each row. If the user checks a box then clicks the delete button which is not on the grid, that row should be deleted. Here's the problem:When the page opens the user can click the delete button and crash the problem. How can I disable that button till at least one checkbox is clicked (true)?

View 4 Replies

AJAX :: How To Confirm Or Delete Work With GridView Delete Button

Dec 14, 2010

I have a Gridview (VS2008 3.5) which has a Edit Button and a Delete button.he Delete button deletes the row without confirming deletion with the user first. ow can I use the Confirm/Delete Confirm from Ajax Toolkitif possible and if not, is there a way to Confirm/Delete with user firstwhen using Gridview?

View 6 Replies

How To Delete A Row From Grid View Without Deleting Database

Jul 26, 2010

I have enter the value in gridview using datarow and ihave allowed user to select particular row using checkbox and pressing delete buttons.

View 8 Replies

Update Delete Insert In Grid View?

Dec 28, 2010

how to update delete and insert records in Grid view

protected void Page_Load(object sender, EventArgs e)
string str = @"data source=MATRIX-0B9AC76C; initial catalog=sam; integrated security=SSPI; ";
SqlConnection con = new SqlConnection(str );
SqlDataAdapter da = new SqlDataAdapter("select * from customer",con );
DataSet ds = new DataSet();
da.Fill(ds, "customer");
GridView1.DataSource = ds;

View 4 Replies

Copyrights 2005-15, All rights reserved