How do I read from a datasource and write to xml (rss)? using asp.net either gridview or form. I'm using this code behind.
Imports
System.Web
System.Web.UI
System.Web.UI.WebControls
System.Net
System.Xml
System.IO
System.Linq
System.Data
System.Xml.XmlWriter
Partial
Public Class XML
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
BindGridView()
End If
End Sub
Protected Sub BindGridView()
Dim dsGridViewXMLEditDeleteUpdate As New DataSet()
dsGridViewXMLEditDeleteUpdate.ReadXml(Server.MapPath(
"./App_Data/XMLFile.xml"))
gridviewXMLInsertEditDelete.DataSource = dsGridViewXMLEditDeleteUpdate
gridviewXMLInsertEditDelete.DataBind()
gridviewXMLInsertEditDelete.ShowFooter =
True
Protected Sub gridviewXMLInsertEditDelete_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs)
Dim dsGridViewXMLDelete As DataSet = DirectCast(gridviewXMLInsertEditDelete.DataSource, DataSet)
dsGridViewXMLDelete.Tables(0).Rows(gridviewXMLInsertEditDelete.Rows(e.RowIndex).DataItemIndex).Delete()
dsGridViewXMLDelete.WriteXml(Server.MapPath(
Protected Sub gridviewXMLInsertEditDelete_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs)
False
gridviewXMLInsertEditDelete.EditIndex = e.NewEditIndex
Protected Sub gridviewXMLInsertEditDelete_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
Dim index As Integer = gridviewXMLInsertEditDelete.Rows(e.RowIndex).DataItemIndex
Dim Title As String = DirectCast(gridviewXMLInsertEditDelete.Rows(e.RowIndex).FindControl("txtTitle"), TextBox).Text
Dim Link As String = DirectCast(gridviewXMLInsertEditDelete.Rows(e.RowIndex).FindControl("txtLink"), TextBox).Text
Dim Description As String = DirectCast(gridviewXMLInsertEditDelete.Rows(e.RowIndex).FindControl("txtDescription"), TextBox).Text
gridviewXMLInsertEditDelete.EditIndex = -1
Dim dsUpdateXMLFile As DataSet = DirectCast(gridviewXMLInsertEditDelete.DataSource, DataSet)
dsUpdateXMLFile.Tables(0).Rows(index)(
"Title") = Title
"Link") = Link
"Description") = Description
dsUpdateXMLFile.WriteXml(Server.MapPath(
Protected Sub gridviewXMLInsertEditDelete_RowCancelingEdit(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs)
Protected Sub gridviewXMLInsertEditDelete_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
If e.CommandName = "InsertXMLData" Then
Dim Title As String = DirectCast(gridviewXMLInsertEditDelete.FooterRow.FindControl("txtTitleInsert"), TextBox).Text
Dim Link As String = DirectCast(gridviewXMLInsertEditDelete.FooterRow.FindControl("txtLinkInsert"), TextBox).Text
Dim Description As String = DirectCast(gridviewXMLInsertEditDelete.FooterRow.FindControl("txtDescriptionInsert"), TextBox).Text
Dim dsXMLInsert As DataSet = DirectCast(gridviewXMLInsertEditDelete.DataSource, DataSet)
Dim drInsert As DataRow = dsXMLInsert.Tables(0).NewRow()
drInsert(
dsXMLInsert.Tables(0).Rows.Add(drInsert)
dsXMLInsert.WriteXml(Server.MapPath(
End
Class