Confirmation message for delete link button conflict with edit's cancel link button

Hello,

I have used the tutorial of ASP.net's confirmation message for the delete link button of the gridview, but it conflict with the edit's cancel link button.

Would somebody teach me how to fix it?

Thanks.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs  e)
    {
      
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // reference the Delete LinkButton
           LinkButton db = (LinkButton)e.Row.Cells[0].Controls[2];
           
            //Get information about the product bound to the row
            InfoTypeDAL.Info_TypeRow infotypeRow =
                (InfoTypeDAL.Info_TypeRow)((System.Data.DataRowView)e.Row.DataItem).Row;

            db.OnClientClick = string.Format(
                "return confirm('Are you certain you want to delete the {0}?');",
                infotypeRow.Info_Type.Replace("'", @"\'"));

            // Implementing Optimistic Concurrency

            ViewState["original_Info_Type"] = e.Row.Cells[2].Text;
       
       
       
        }

 The code of my gridview:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                    DataKeyNames="RecID" DataSourceID="ObjectDataSource1"
                    OnRowDataBound="GridView1_RowDataBound"
                    onrowupdated="GridView1_RowUpdated">
                    <Columns>
                        <asp:CommandField ShowDeleteButton="True"
                         ShowEditButton="True"/>
                        <asp:BoundField DataField="RecID" HeaderText="RecID"
                            SortExpression="RecID" ReadOnly="True" />
                        <asp:BoundField DataField="Info_Type" HeaderText="Info_Type"
                            SortExpression="Info_Type" />
                        <asp:CheckBoxField DataField="RecStatus" HeaderText="RecStatus"
                            SortExpression="RecStatus" ReadOnly="True" />
                        <asp:BoundField DataField="RecStatusDT" HeaderText="RecStatusDT"
                            SortExpression="RecStatusDT" ReadOnly="True" />
                    </Columns>
                </asp:GridView>


Thanks!

Wu
0
wuchunwai
12/28/2008 7:57:47 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

5 Replies
1385 Views

Similar Articles

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

Hi wuchunwai ,

 

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowState == DataControlRowState.Normal)
        {
            //put your code here !!!
        }
    }
 

Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Samu
12/30/2008 5:46:14 AM

Hi Samu Zhang,

Glade to see your reply.

 May I confirm the code should looks like the below or not?  I am newbie

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowState == DataControlRowState.Normal)
 {
            // reference the Delete LinkButton
           LinkButton db = (LinkButton)e.Row.Cells[0].Controls[2];
           
            //Get information about the product bound to the row
            InfoTypeDAL.Info_TypeRow infotypeRow =
                (InfoTypeDAL.Info_TypeRow)((System.Data.DataRowView)e.Row.DataItem).Row;

            db.OnClientClick = string.Format(
                "return confirm('Are you certain you want to delete the {0}?');",
                infotypeRow.Info_Type.Replace("'", @"\'"));

            // Implementing Optimistic Concurrency

            ViewState["original_Info_Type"] = e.Row.Cells[2].Text;
       
        }
       
        }

 Thanks

Wu


Thanks!

Wu
0
wuchunwai
12/30/2008 8:04:52 AM

Hi wuchunwai ,

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowState == DataControlRowState.Normal)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // reference the Delete LinkButton
           LinkButton db = (LinkButton)e.Row.Cells[0].Controls[2];
           
            //Get information about the product bound to the row
            InfoTypeDAL.Info_TypeRow infotypeRow =
                (InfoTypeDAL.Info_TypeRow)((System.Data.DataRowView)e.Row.DataItem).Row;

            db.OnClientClick = string.Format(
                "return confirm('Are you certain you want to delete the {0}?');",
                infotypeRow.Info_Type.Replace("'", @"\'"));

            // Implementing Optimistic Concurrency

            ViewState["original_Info_Type"] = e.Row.Cells[2].Text;
       
       
       
        }


        }
    }



Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Samu
1/2/2009 9:05:27 AM

Hi Samu Zhang ,

Thanks for your advice.  I really appreciate it. Happy New Year.

 


Thanks!

Wu
0
wuchunwai
1/5/2009 3:09:48 AM

Hi Samu Zhang,

Would you advice why my following code does not work after additional condition has been added?  Thanks

protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)

{

LinkButton db = new LinkButton();if (e.Row.RowType == DataControlRowType.DataRow)

{

if (e.Row.RowState == DataControlRowState.Normal)

{

// reference the Edit LinkButton

db = (LinkButton)e.Row.Cells[0].Controls[0];

//Get information about the information data bound to the row

RequestITOptimisticConcurrency.Info_DataOptimisticConcurrencyRow infodataRow =

(RequestITOptimisticConcurrency.Info_DataOptimisticConcurrencyRow)((System.Data.DataRowView)e.Row.DataItem).Row;

db.OnClientClick = string.Format(

"return confirm('Are you certain you want to edit the information type: {0}?');",

infodataRow.InfoData.Replace("'", @"\'"));

// Implementing Optimistic Concurrency

ViewState["original_Info_Data"] = e.Row.Cells[2].Text;

} //

else

{

if (db == (LinkButton)e.Row.Cells[0].Controls[2])

{

// reference the update LinkButton

// LinkButton db = (LinkButton)e.Row.Cells[0].Controls[2];

//Get information about the information data bound to the row

RequestITOptimisticConcurrency.Info_DataOptimisticConcurrencyRow infodataRow =

(RequestITOptimisticConcurrency.Info_DataOptimisticConcurrencyRow)((System.Data.DataRowView)e.Row.DataItem).Row;

db.OnClientClick = string.Format(

"return confirm('Are you certain you want to cancel the amendment of information type: {0}?');",

infodataRow.InfoData.Replace("'", @"\'"));

// Implementing Optimistic Concurrency

ViewState["original_Info_Data"] = e.Row.Cells[2].Text;

}

else

{

//reference the Cancel LinkButton

//LinkButton db = (LinkButton)e.Row.Cells[0].Controls[0];

//Get information about the information data bound to the row

RequestITOptimisticConcurrency.Info_DataOptimisticConcurrencyRow infodataRow =

(RequestITOptimisticConcurrency.Info_DataOptimisticConcurrencyRow)((System.Data.DataRowView)e.Row.DataItem).Row;

db.OnClientClick = string.Format(

"return confirm('Are you certain you want to update the amendment of information type: {0}?');",

infodataRow.InfoData.Replace("'", @"\'"));

// Implementing Optimistic Concurrency

ViewState["original_Info_Data"] = e.Row.Cells[2].Text;

}

}

}

}

 Thanks!

Wu


Thanks!

Wu
0
wuchunwai
1/6/2009 2:33:29 AM
Reply:

Similar Artilces:

How to change the 'edit' button to 'Update'+'Cancel' button in Gridview
Hi all, I'm using a commandField 'edit' button in a Gridview which I hope to be changed to a 'update' and a 'cancel' button when the 'edit' button is pushed. My codes are as follow.  My problem is that I don't know what codes should be added to make the change I mentioned to happen. THanks a lot for your assistance. TOny<%@ Page Language="VB" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><%@ Import Namespace="syste...

overwrite link button's status bar message
 Hello All ! I have a very small possibly stupid doubt. I am using link button in some place. when my mouse is on the link button (on mouse over) I can see some information regarding the link button in the browser's status bar. I am creating that link button dynamically, assigning event handler dynamically and placing it in collapsable panel, which is also created dynamically. everything is working fine. however, i dont want that information to appear on the status bar. I have attached a screenshot here:          I dont want that Javascri...

How to Add tool tip to an DataGrid Edit Column's link button
Following is Edit command column's  code ,i want to add tool tip to the link button<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="<IMG SRC=../../images/icons/save.gif border=0>" HeaderText="Modify" CancelText="<IMG SRC=../../images/icons/cancel.gif border=0>" EditText="<IMG SRC=../../images/icons/modify.gif border=0>"> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center"></ItemStyle> </asp:EditCo...

Link for a link button
Hey Guys I have a link button and i need to pass a url to it. how do it do it. hyperlink has navigate url but how to do it for link button. Thanks in advance cheers There is no property available to set the url to a link button. you can use the OnClick event of the linkbutton to do the action       void LinkButton1_Click(Object sender, EventArgs e)       {         // do some action here      }    <form runat="server">      &l...

Link Button or Button
The navigation on my web site uses buttons instead of link buttons because I can better customize the look that I want with buttons over link buttons. If I go to my search page which consists of a textbox, validation control, and search button, I can not navigate to another page(using the buttons) until I fulfill the validation control by entering a value in the text box. Any way I can get around this? The navigation buttons use a simple response.redirect line of code. Thanks. You've just encountered the main problem with client-side validation controls. What's happening is that your va...

Simple 'Confirm' on Link Button click
I have a simple Link Button which fires even "LinkButton1_Click" as follows:   Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click if("javascript:return confirm('Are you sure?');") then 'do some stuff Response.Redirect("another page") else 'do some other stuff Response.Redirect("another page") end ifend sub How can I make something like this work? I'm new to web development, and this is probably a simple problem. Obv...

superreview cancelled: [Bug 146075] 'Message > Edit Message As New' (== 'Edit As New...') set an incorrect initial "X-Priority:" value (when present), which messes up 'Options > Priority' U.I. also :
Serge GAUTHERIE <gautheri@noos.fr> has cancelled Jean-Francois Ducarroz <ducarroz@aol.net>'s request for superreview: Bug 146075: 'Message > Edit Message As New' (== 'Edit As New...') set an incorrect initial "X-Priority:" value (when present), which messes up 'Options > Priority' U.I. also http://bugzilla.mozilla.org/show_bug.cgi?id=146075 Attachment 136206: (Av2) 'mime_generate_headers()' http://bugzilla.mozilla.org/attachment.cgi?id=136206&action=edit ...

Button Button who's got the Button
I just started learning Visual Studio.NET so I'm sure there is some stupid setting I am overlooking, but here is my dilema. I've created a new webform WebForm1.aspx. Then I have placed a Button control on my webform and added some simple C# code to the Click event. Last I Build and Browse WebForm1.aspx, but lo and behold no button! I view the source and I can see the code for the button but it won't show in the browser. So I looked around and found another Button control on the HTML section of the toolbox. When I place that on my webform with the same C# click code, the button does show on t...

superreview cancelled: [Bug 146075] 'Message > Edit Message As New' (== 'Edit As New...') set an incorrect initial "X-Priority:" value (when present), which messes up 'Options > Priority' U.I. also; a #2
Serge GAUTHERIE <gautheri@noos.fr> has cancelled Serge GAUTHERIE <gautheri@noos.fr>'s request for superreview: Bug 146075: 'Message > Edit Message As New' (== 'Edit As New...') set an incorrect initial "X-Priority:" value (when present), which messes up 'Options > Priority' U.I. also; and code cleanup. http://bugzilla.mozilla.org/show_bug.cgi?id=146075 Attachment 150091: (Ev1) 'Options > Priority > ...' menu http://bugzilla.mozilla.org/attachment.cgi?id=150091&action=edit ...

superreview cancelled: [Bug 146075] 'Message > Edit Message As New' (== 'Edit As New...') set an incorrect initial "X-Priority:" value (when present), which messes up 'Options > Priority' U.I. also; a #3
Serge GAUTHERIE <gautheri@noos.fr> has cancelled Serge GAUTHERIE <gautheri@noos.fr>'s request for superreview: Bug 146075: 'Message > Edit Message As New' (== 'Edit As New...') set an incorrect initial "X-Priority:" value (when present), which messes up 'Options > Priority' U.I. also; and code cleanup. https://bugzilla.mozilla.org/show_bug.cgi?id=146075 Attachment 150073: (Av2f) 'mime_generate_headers()' https://bugzilla.mozilla.org/attachment.cgi?id=150073&action=edit ...

GridView edit mode Edit/Delete link become button
The standard Gridview edit mode provides "Edit" and "Delete" hyperlink (called linked button) for us to click and update record. How to make them buttons instead of hyperlik ? I could not find the codes for these 2 default hyperlinks to modify. ThanksThanks in advance for the help. I will try to credit the ones who helped but most important is we really do sincerely thanks to all who have helped. I found the solution. We can edit column and then change from link to button.  Thanks in advance for the help. I will try to credit the ones who helped but most import...

Help with javascript/link button/changing link button text
I have read various posts and articles on the web, but for some reason I can't get this to work. Not sure if it is because I use master pages and so the javascript is not declared in the header tag? Ultimately, what I am try to achieve is this. I have a link button, the default text is "miles". When the user clicks on the link button it should change to "kilometres". So, basically a user can keep clicking on the button the and text should change to either miles or kilometres. I can get this to work ok with vb but I need to avoid a postback to the server and so use ja...

HELP
Hello... I have a strange situation happening, and I thought maybe I could get some assistance. I have created a simple user control (.ascx) file that's part of my default.aspx page. The user control contains a link button control, such as: <asp:LinkButton id="idLinkButtonopenAll" runat="server">open all</asp:LinkButton> Then in my code-behind file, I have it's event handler, such as: public class reports : System.Web.UI.UserControl { protected System.Web.UI.WebControls.LinkButton idLinkButtonopenAll; private void Page_Load(object se...

how to restore deleted edit,delete,new link buttons in form view
i am using visual web developer 2005 and SQL Express 2005 with VB as the code behindwhen we add a form view to our page , by default it contains edit , delete , new  link buttonsby mistake i deleted those buttonshow to bring them back without creating a new form view from the beginning moreover those  edit , delete , new are by default link buttons. how to make them into conventional buttons ?please help me  Go into the Source view, and add <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"    Text="Edit" /> as...

Web resources about - Confirmation message for delete link button conflict with edit's cancel link button - asp.net.presentation-controls

Confirmation - Wikipedia, the free encyclopedia
A bishop administering Confirmation. Rogier van der Weyden , The Seven Sacraments , 15th century. normally carried out through anointing , the ...

Confirmation - Wikipedia, the free encyclopedia
A bishop administering Confirmation. Rogier van der Weyden , The Seven Sacraments , 15th century. normally carried out through anointing , the ...

Facebook Reportedly Acquires Gowalla, No Confirmation From Either Company
... “most” of its employees and founder Josh Williams over to Palo Alto headquarters to work on Timeline, according to CNN. We could not get confirmation ...

Twitter reactions to the #Fed confirmation
... over Twitter — the last time that a new chairperson was appointed, Twitter wasn’t around. Within half an hour of the milestone confirmation, ...

Senate Confirmation Hearing (200910150008HQ) - Flickr - Photo Sharing!
U.S. Sen. Jay Rockefeller, D-W.Va., Chairman of the of the Senate Committee on Commerce, Science and Transportation, makes a point during the ...

Wet Hot American Summer: First Day of Camp - Cast Confirmation - Netflix - HD - YouTube
The counselors are confirmed for Wet Hot American Summer: First Day of Camp, a limited 8-episode series coming to Netflix just in time for summer. ...

Barry O'Sullivan's Senate confirmation delayed
Queensland will be without one of its senators until at least February next year.

Is this confirmation Prince George and Princess Charlotte's nanny is Mary Poppins?
The christening of Princess Charlotte was touted as &quot;modern&quot;. No one told the nanny.

Jurgen Klopp Liverpool, Jurgen Klopp news, Jurgen Klopp Liverpool confirmation
JURGEN Klopp is officially the new Liverpool manager.

Is this confirmation Prince George and Princess Charlotte's nanny is Mary ...
Sydney Morning Herald Is this confirmation Prince George and Princess Charlotte's nanny is Mary ... Sydney Morning Herald There were many ...

Resources last updated: 12/26/2015 3:03:42 AM