I have a gridview with the following code... it successfully updates
my row but I'd like it to resume the normal row appearance rather than
leave the textbox open. Currently the only way to achieve this is to
hit the Edit button on another row. I'd like to use the
'KeepInEditMode' property but I can't find an example of where to use
it in my code. Also what is the appropriate code to put in the event
hanler for the "Cancel" button? Thanks!!

<%@ import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml.XPath" %>
<%@ Import Namespace="System.Xml" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not IsPostBack Then
bind()
End If
End Sub 'Page_Load

Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As
GridViewEditEventArgs)
Me.GridView1.EditIndex = e.NewEditIndex
bind()
End Sub

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
GridViewUpdateEventArgs)
Dim originalId As String = GridView1.DataKeys
(e.RowIndex).Value.ToString()
Dim id As String = CType(GridView1.Rows(e.RowIndex).Cells(0).Controls
(0), TextBox).Text
Dim id As String = CType(GridView1.Rows(e.RowIndex).Cells(1).Controls
(0), TextBox).Text
Dim year As String = CType(GridView1.Rows(e.RowIndex).Cells(2).Controls
(0), TextBox).Text
Dim subject As String = CType(GridView1.Rows(e.RowIndex).Cells
(3).Controls(1), TextBox).Text
Dim doc As New System.Xml.XmlDocument()
doc.Load(Server.MapPath("history1.xml"))
Dim node As System.Xml.XmlNode = doc.SelectSingleNode(("//row[id='" +
originalId + "']"))
Dim nodeid As System.Xml.XmlNode = node.SelectSingleNode("id")
Dim nodesubject As System.Xml.XmlNode = node.SelectSingleNode
("subject")
Dim nodeyear As System.Xml.XmlNode = node.SelectSingleNode("year")
nodeid.InnerText = ID
nodesubject.InnerText = subject
nodeyear.InnerText = year
doc.Save(Server.MapPath("history1.xml"))
bind()
End Sub


Private Sub bind()
Dim ds As New DataSet()
ds.ReadXml(Server.MapPath("history1.xml"))
Me.GridView1.DataSource = ds
GridView1.DataBind()
End Sub 'bind

Reply via email to