473,792 Members | 2,937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

not understanding updating/deleting with gridview

When you specify updateparameter s or deleteparameter s for your gridview,
I was under the impression that whether or not you write some code in
the rowcommand event to deal with this, the update or delete happens
anyway. For example, I have a gridview like this :

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>"

SelectCommand=" GetOppsTypeList " SelectCommandTy pe="StoredProce dure"

UpdateCommand=" UpdateOpportuni ty" UpdateCommandTy pe="StoredProce dure"

DeleteCommand=" DeleteOpportuni ty" DeleteCommandTy pe="StoredProce dure">

<SelectParamete rs>

<asp:QueryStrin gParameter Name="CompanyKe y"
QueryStringFiel d="CompanyKey " Type="Int64" />

<asp:QueryStrin gParameter Name="Opportuni tyName"
QueryStringFiel d="OpportunityN ame" Type="Int32" />

<asp:ControlPar ameter Name="Status" ControlID="ddlS tatus"
PropertyName="S electedValue" DefaultValue="A ll" />

</SelectParameter s>

<UpdateParamete rs>

<asp:Paramete r Name="Opportuni tyTypeID" Type="Int32" />

<asp:Paramete r Name="DivisionI D" Type="Int32" />

<asp:Paramete r Name="XeroxMach ineType" Type="String" />

<asp:Paramete r Name="Model" Type="String" />

<asp:Paramete r Name="Probabili tyID" Type="Int32" />

<asp:Paramete r Name="MonetaryV alue" Type="Double" />

<asp:Paramete r Name="Opportuni tyID" Type="Int32" />

</UpdateParameter s>

<DeleteParamete rs>

<asp:Paramete r Name="Opportuni tyID" Type="Int32" />

</DeleteParameter s>

And here are the relevant columns :

<asp:ButtonFiel d ButtonType="Ima ge" ImageUrl="~/Images/btnAddLog.jpg"
CommandName="Ad dLog" />

<asp:ButtonFiel d ButtonType="Ima ge" ImageUrl="~/Images/btnDetails.jpg"
CommandName="Op portunityDetail s" />
<asp:CommandFie ld ShowEditButton= "True" ButtonType="Ima ge"
EditImageUrl="~/Images/btnEdit.jpg"

CancelImageUrl= "~/Images/btnCancel.jpg"
UpdateImageUrl= "~/Images/btnUpdate.jpg"/>
<asp:TemplateFi eld>

<ItemTemplate >

<asp:ImageButto n ID="DeleteButto n"

ImageUrl="~/Images/btnDelete.jpg"

CommandName="De lete" runat="server"

CommandArgument ='<%# Eval("Opportuni tyID") %>'

OnClientClick=" return confirm('Are you sure you want to delete this
opportunity?'); ">

</asp:ImageButton >

</ItemTemplate>

</asp:TemplateFie ld>

Now when I want to 'Add Log', a command I have created myself, I need to
do so here :

protected void GridView1_RowCo mmand(object sender,
GridViewCommand EventArgs e)

{

if (e.CommandName == "AddLog")

{

}

But for a delete, if I have delete parameters specified, the delete
takes place without the need for any code in the rowcommand event. But
why is this not the case for the update? I was trying to validate
deletions in the rowcommand event, but found that the delete had already
taken place before it reached this event, whilst I was able to validate
the update event with custom code in the rowcommand event, as the update
did not happen before the rowcommand event was reached.

Why does it happen like this?


*** Sent via Developersdex http://www.developersdex.com ***
Aug 3 '06 #1
0 1959

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2034
by: P | last post by:
Hello, I am having a difficult time updating a record via a stored procedure using the gridview and sqldatasource. I cannot seem to be able to find a way to set everything up so that I can pass the applicable fields in the gridview to a sqldatasource which in turn calls a sproc with the appropriate parameters and data. Any ideas? Thanks in advance,
3
6338
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data correctly but it is not updating or deleting the rows. What I did was, in design view, added a gridview control and added an sqldatasource control. I configured the data source to update and delete. In the gridview tasks I selected enable...
3
2235
by: adam222 | last post by:
hello, i have a web-form with a GridView control, i wanted to update & delete, using the AutoGenerateEditButton. when i used it with sqlDataSource (executing SP in the DB) it works like a charm, but when i want to pass the data through the application's layers (BL etc.), it did not work. it seems that the 'AutoGenerateEditButton' is capable only with sqlDataSource...
5
2249
by: Michael | last post by:
Hi Everyone, I've been having a problem with the Gridview control. I have posted a few messages relating to the issues, but I have a general question. Does the Dataview control have to be bound to a datasource that also contains the update/delete Sql statements? The resaon I ask is that I've done just about all I can do and can't update the grid. In the RowUpdating event I'm getting no values in the newvalues or oldvalues vars. I do bind a...
1
4701
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
Hi, I have a gridview which I added a <asp:CommandField EditText="E" CancelText="C" UpdateText="U" ButtonType="Link" ShowEditButton="True" /> my gridview looks like this <asp:GridView ID="GridView1" runat="server" OnRowEditing="RowEdit" OnRowCancelingEdit="RowCancel" OnRowUpdating="RowUpdating"...
4
8762
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I setup a simple gridview as a utility just to do some updates, nothing fancy just wanted easy UI to make updates. When I select ‘Edit’, I get the fields I want to edit. I edit them and click ‘Update’, the page returns to its original state (prior to clicking Edit) and no updates occur in the DB. What am I missing? I included the html code below. -- Thank-you, Barbara Alderton <body>
0
1556
by: TheDebbis | last post by:
I'm making a quick CD catalog to help me learn ASP.NET (using C# primarily.) I have a number of gridview's on my site that are working properly, but for some reason, one is not updating or deleting. I have the buttons for both visible, and when I click edit, the update fields show up properly, but once I click 'update' the table is back with it's old information. When I click 'delete' the page completes the postback properly, but once again, the...
0
4282
by: steve | last post by:
I have been fighting with trying to update a GridView for a while. I don't want to use the "built-in" way to do it because I am using business layer methods for updating and deleteing and I don't want to have my parameter names in those methods have to be "original_Parametername" or even if I change the OldValuesParameterFormatString to get rid of the "original" I would still have just "Parametername". I think most people user parameters...
0
1279
by: BizWeb | last post by:
Hi, i am new to ASP.NET. I have write a very simple code to try the updating of the GridView but it is not updating the data. Below is the simple code that i have use. <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
0
9518
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10430
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10211
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10159
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6776
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4111
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
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.