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 ***