12
Answers

how to implemnet scrolling news from xml in to asp.net page


This is my code behind page...when i load xml content to label in asp.net page only table[0][0] index is loaded i want to load whole xml content in to my asp page...like paragraph format....my idea to implent scrollin news in my webpage.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Data;


public partial class NewsEventsUsingXML : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {

            //Bind xml data to datalist

            BindDatalist();

        }

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        XmlDocument XmlTxt = new XmlDocument();
        XmlTxt.Load(Server.MapPath("XMLFile2.xml"));
        XmlElement ParentElement = XmlTxt.CreateElement("News1");
        XmlElement News = XmlTxt.CreateElement("News");
        News.InnerText = txtNews.Text;
        ParentElement.AppendChild(News);
        XmlTxt.DocumentElement.AppendChild(ParentElement);
        XmlTxt.Save(Server.MapPath("XMLFile2.xml"));

    }

    private void BindDatalist()
    {
        XmlTextReader XmlReader1 = new XmlTextReader(Server.MapPath("XMLFile2.xml"));
        DataSet Xmlds1 = new DataSet();
        Xmlds1.ReadXml(XmlReader1);
        XmlReader1.Close();
        lblNews.Text = Xmlds1.Tables[0].Rows[0][0].ToString();
        lblNews.Text=Xmlds1.Tables[0].Rows[1][0].ToString();
        lblNews.Text = Xmlds1.Tables[0].Rows[6][0].ToString();
        lblNews.DataBind();
        //GridView1.DataSource = Xmlds1;
        //GridView1.DataBind();

    }
}
Answers (12)