Posted By

tabook22 on 07/11/11


xml aspnet GridView vbne

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Saving data from gridview to xml file

 / Published in: VB.NET

this code will show you how to save data from gridview to xml file

  1. Protected Sub GridView1_RowCommand(sender As Object, e As GridViewCommandEventArgs)
  2. If e.CommandName = "save" Then
  3. Dim st As String = Server.MapPath("emp.xml")
  4. Dim ds As New DataSet()
  5. ds.ReadXml(st)
  6. Dim r As DataRow = ds.Tables(0).NewRow()
  7. r(0) = Convert.ToInt32(DirectCast(GridView1.FooterRow.FindControl("TextBox1"), TextBox).Text)
  8. r(1) = DirectCast(GridView1.FooterRow.FindControl("TextBox3"), TextBox).Text
  9. r(2) = DirectCast(GridView1.FooterRow.FindControl("TextBox5"), TextBox).Text
  10. r(3) = Convert.ToInt32(DirectCast(GridView1.FooterRow.FindControl("TextBox7"), TextBox).Text)
  11. ds.Tables(0).Rows.Add(r)
  12. ds.WriteXml(st)
  13. getxml()
  14. End If
  15. End Sub

Report this snippet  

You need to login to post a comment.