Heres the scoop:
I am writing a basic "entry" page for a database using the gridview, I set the gridviews properties to autogenerate edit/delete buttons.
When the page initalizes I create a blank dataset and bind that dataset to the grid.
After the dataset is bound I can click on edit/delete and it fires the appropriate command:
Edit fires RowEditing
Delete fires RowDeleting
However, after the row is then enabled the update/cancel commands
DO NOT fire the right appropriate command.
Update fires RowEditing
Cancel fires RowDeleting
Below is a basic program that I whipped up to show an example:
--ASPX--
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<b>Car Name:</b><br />
<asp:TextBox ID="carNewName" runat="server" Visible="true" TextMode="singleLine"></asp:TextBox><br />
<b>Car Description:</b><br />
<asp:TextBox ID="carNewDesc" runat="server" Visible="true" TextMode="singleLine"></asp:TextBox><br />
<b>Car Details:</b><br />
<asp:GridView ID="grdCarNew" runat="server" Visible="true" AutoGenerateColumns="false" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true">
<Columns>
<asp:BoundField HeaderText="Make" DataField="Location" />
<asp:BoundField HeaderText="Model" DataField="City" />
<asp:BoundField HeaderText="Year" DataField="State" />
<asp:BoundField HeaderText="Damage" DataField="Zip" />
<asp:BoundField HeaderText="Final Condition" DataField="County" />
<asp:BoundField HeaderText="Estimated Worth" DataField="SPLC" />
<asp:TemplateField HeaderText="Sale Country">
<EditItemTemplate>
<asp:DropDownList ID="ddlCountry" runat="server" DataTextField="description" DataValueField="code" DataSource=<%#DataSetCountries%
></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>--VB.NET CODE BEHIND--
Sub
page_init(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Init
'Create a base dataset for use with the gridview
If Session("dtsTemp") Is Nothing Then
Dim dtsTemp As New DataSet
Dim dtrRgn As DataRow
If dtsTemp.Tables.Count = 0 Then
With dtsTemp
.Tables.Add(0)
.Tables(0).Columns.Add("Make")
.Tables(0).Columns.Add("Model")
.Tables(0).Columns.Add("Year")
.Tables(0).Columns.Add("Damage")
.Tables(0).Columns.Add("Final_Condition")
.Tables(0).Columns.Add("Estimated_Worth")
.Tables(0).Columns.Add("Sale_Country")
'Create the data row that will add the first row to the grid
dtrRgn = dtsTemp.Tables(0).Rows.Add(0)
With dtrRgn
.Item(0) = ""
.Item(1) = ""
.Item(2) = ""
.Item(3) = ""
.Item(4) = ""
.Item(5) = ""
End With
End With
End If
'Set the dtsTemp to the session variable
Session("dtsTemp") = dtsTemp
End If
'Bind the Dataset to the data grid
bindGrid()
End Sub
Sub
bindGrid()
With grdCarNew
.DataSource = Session("dtsTemp")
.DataBind()
End With
End Sub
'Example of the editing handler
Sub grdResultEdit(ByVal sender As Object, ByVal e As GridViewEditEventArgs) Handles grdRgnNew.RowEditing
Dim strSQL As String
strSQL = "SELECT * FROM gimmecountries WHERE codetype = 'country'"
'DataSetCountries is a Protected dataset declared in a region above this code
DataSetCountries = SqlHelper.ExecuteDataset(dbMain, CommandType.Text, strSQL)
With grdRgnNew
.EditIndex = e.NewEditIndex
bindGrid()
End With
End SubAny way I hope this gives a basic idea of what I am doing. Is it me that is improperly handling this type of item or is it that vs 2005 beta 2 has a bug in the framework that calls the improper handler if your not using a SqlDataSource for the gridview?
Thanks for the Time
-Cryptic