473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

not understanding updating/deleting with gridview

When you specify updateparameters or deleteparameters 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:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

SelectCommand="GetOppsTypeList" SelectCommandType="StoredProcedure"

UpdateCommand="UpdateOpportunity" UpdateCommandType="StoredProcedure"

DeleteCommand="DeleteOpportunity" DeleteCommandType="StoredProcedure">

<SelectParameters>

<asp:QueryStringParameter Name="CompanyKey"
QueryStringField="CompanyKey" Type="Int64" />

<asp:QueryStringParameter Name="OpportunityName"
QueryStringField="OpportunityName" Type="Int32" />

<asp:ControlParameter Name="Status" ControlID="ddlStatus"
PropertyName="SelectedValue" DefaultValue="All" />

</SelectParameters>

<UpdateParameters>

<asp:Parameter Name="OpportunityTypeID" Type="Int32" />

<asp:Parameter Name="DivisionID" Type="Int32" />

<asp:Parameter Name="XeroxMachineType" Type="String" />

<asp:Parameter Name="Model" Type="String" />

<asp:Parameter Name="ProbabilityID" Type="Int32" />

<asp:Parameter Name="MonetaryValue" Type="Double" />

<asp:Parameter Name="OpportunityID" Type="Int32" />

</UpdateParameters>

<DeleteParameters>

<asp:Parameter Name="OpportunityID" Type="Int32" />

</DeleteParameters>

And here are the relevant columns :

<asp:ButtonField ButtonType="Image" ImageUrl="~/Images/btnAddLog.jpg"
CommandName="AddLog" />

<asp:ButtonField ButtonType="Image" ImageUrl="~/Images/btnDetails.jpg"
CommandName="OpportunityDetails" />
<asp:CommandField ShowEditButton="True" ButtonType="Image"
EditImageUrl="~/Images/btnEdit.jpg"

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

<ItemTemplate>

<asp:ImageButton ID="DeleteButton"

ImageUrl="~/Images/btnDelete.jpg"

CommandName="Delete" runat="server"

CommandArgument='<%# Eval("OpportunityID") %>'

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

</asp:ImageButton>

</ItemTemplate>

</asp:TemplateField>

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

protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs 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 1944

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

Similar topics

1
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...
3
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...
3
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...
5
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...
1
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...
4
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...
0
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....
0
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...
0
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"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.