473,546 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to avoid postback on delete button inside gridview when selecting cancel confirma

5 New Member
Hi to all .NET guru guys...

I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation. What happened is if I select cancel on my confirmation button, it executes the griedview postback which i assigned in my code behind. Please see my codes below...

Code beind:

protected void gvDefectCatalog _RowDataBound(o bject sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
e.Row.Attribute s["onmouseove r"] = "javascript:Gri dViewMouseOverC olor(this);";
e.Row.Attribute s["onmouseout "] = "javascript:Gri dViewMouseOutCo lor(this);";
e.Row.Attribute s.Add("onclick" , ClientScript.Ge tPostBackEventR eference(gvDefe ctCatalog, "Select$" + e.Row.RowIndex. ToString())); }

}


HTML:

<asp:GridView ID="gvDefectCat alog" runat="server" CssClass="GridV iew"
DataKeyNames="d efectID,defectC ode"
AutoGenerateCol umns="False" OnSelectedIndex Changed="gvDefe ctCatalog_Selec tedIndexChanged "
AllowPaging="fa lse" Width="98%" ShowHeader="Fal se" ShowFooter="Fal se" EnableViewState ="true" GridLines="none " CellPadding="0" CellSpacing="0"
OnRowDataBound= "gvDefectCatalo g_RowDataBound"
OnRowCommand="g vDefectCatalog_ RowCommand"
OnRowDeleting=" gvDefectCatalog _RowDeleting"
OnRowEditing="g vDefectCatalog_ RowEditing"
OnRowCancelingE dit="gvDefectCa talog_RowCancel ingEdit"
OnRowUpdating=" gvDefectCatalog _RowUpdating">
<Columns>
<asp:TemplateFi eld>
<ItemTemplate >
<asp:Button ID="btEdit" Text="Edit" CommandName="Ed it" CausesValidatio n="false" runat="server" CssClass="GridV iewButton" Width="35px" TabIndex="14"/>&nbsp;
<asp:Button ID="btnDelete" Text="Delete" CommandName="De lete" runat="server" CommandArgument ='<%# Eval("defectID" ) %>' CssClass="GridV iewButton" Width="40px" TabIndex="15" OnClientClick=" return confirm('Are you sure you want to delete this data?')"/>&nbsp;
</ItemTemplate>
<EditItemTempla te>
<asp:Button Text="Update" CommandName="Up date" CausesValidatio n="true" runat="server" ID="btUpdate" CssClass="GridV iewButton" Width="40px" OnClientClick=" ObjectVisibilit y('UpdateProgre ss')" TabIndex="12"/>&nbsp;
<asp:Button Text="Cancel" CommandName="Ca ncel" CausesValidatio n="false" runat="server" ID="btECancel" CssClass="GridV iewButton" Width="40px" OnClientClick=" ObjectVisibilit y('UpdateProgre ss')" TabIndex="13"/>
</EditItemTemplat e>
<HeaderTemplate >
<asp:Button Text="Insert" CommandName="In sert" CausesValidatio n="true" runat="server" ID="btInsert" CssClass="GridV iewButton" Width="40px" OnClientClick=" ObjectVisibilit y('UpdateProgre ss')" TabIndex="12"/>
<asp:Button Text="Cancel" CommandName="Ca ncel" CausesValidatio n="false" runat="server" ID="btICancel" CssClass="GridV iewButton" Width="40px" OnClientClick=" ObjectVisibilit y('UpdateProgre ss')" TabIndex="13"/>
</HeaderTemplate>
</asp:TemplateFie ld>

<asp:CommandFie ld ButtonType="Lin k" ShowSelectButto n="true" SelectText="">
<ItemStyle Width="0%" HorizontalAlign ="left" VerticalAlign=" Middle"></ItemStyle>
</asp:CommandFiel d>
</ asp:GridView>
Nov 19 '07 #1
0 2795

Sign in to post your reply or Sign up for a free account.

Similar topics

3
13728
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum. Everyone wants to do a java confirmation box when a user clicks the delete button. Fair enough, basic user design rules state that you should...
3
4740
by: JN | last post by:
I am using the sqldatasource to populate a gridview and I have a pop up that fires when the item_deleting event is triggered. Now in the popup, if the user clicks cancel, i dont want the delete query to continue. How do I accomplish this? Thanks. JN
3
11751
by: Simon Strandgaard | last post by:
Hi group, my setup: I have a GridView that extracts data from my table (a SqlDataSource). For each row, I have an 'edit' button and a 'delete' button. The 'edit' button opens a popup, through which one can insert and edit the table. The 'delete' button deletes the row.
8
12739
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the form. I only want to allow single selection, so using checkboxes is out of the question. It works as is, but it makes the form very cumbersome if...
10
6669
by: Carlos | last post by:
Hi all, I have a form with an input radio control in a template field. When the user selects an option, and press a button the selection disappears.. I would like the selection to persist after the button makes the postback, I tried using the findcontrol but it returns null, and do not know how to make sure that the radio selected...
0
3656
by: Dan | last post by:
Issue making textbox visible based on specific input from a radio button list in an EditItemTemplate I want to setup a gridview that when in edit mode and when the user selects "Other" from a radiolist that a text box will appear and the user can input text. I can get the textbox to appear after selecting other in the radiolist; however,...
0
1419
by: stimul8d | last post by:
Before i get flamed, this isn't the usual question you see left right and center. I'm dynamically creating usercontrols inside the page_init event and setting the ID's of each control so that the events survive postback. in the user control i have a datagrid which uses the old databinding events (updating, editing etc,...). Here's the problem,...
1
1969
by: klaul | last post by:
Hi there. I'm having an issue with autopostback, in that it doesn't seem to be working! The webform I am using pulls the data from an AccessDataSource to populate the gridview, which has Edit and Delete functions. I have also configured it so that I can insert into the gridview using the footer row. What I am now trying to do is create two...
4
3998
by: tiago.private | last post by:
Hi everybody, Imagine the following scenario: One System.Web.UI.UserControl (UC1) with 2 drop downs and one button "Filter" One Webform with (UC1) and a GridView, basically the UC1 provides the options to the user to restrict (filter) the grid. The user changes the drop downs and then uses the Filter button to filter data (grid) that...
0
7435
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7461
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.