Hi, need help on finding why code won't run. Keep getting code error: No overload for 'DisplayXML' matches delegate 'System.Web.UI.WebControls.SqlDataSourceSelectingEventHandler'
Would appreciate any help......

System pointing to the following code saying its the cause, but don't know how to fix it:

<asp:SqlDataSource
        id="srcProducts"
        SelectCommand="SELECT * FROM PRODUCT"
        ConnectionString="Data Source=.\SQLExpress;AttachDbFilename=|DataDirectory|MyDatabase.mdf;Integrated Security=True;User Instance=True"
        Runat="server" onselecting="DisplayXML" />







<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


<script runat="server">

    public void btnXML_Create(object sender, EventArgs e)
    {
        string _conString = srcProducts.ConnectionString;
        string strSQL = "SELECT * FROM PRODUCT";
        DataSet ds = new DataSet("PRODUCT");
        SqlDataAdapter productsSDA = new SqlDataAdapter(strSQL, _conString);
        SqlConnection cn = new SqlConnection(strSQL);
        productsSDA.Fill(ds, "PRODUCT");
        ds.WriteXml(Server.MapPath("~/DOM/xml/movieDb.xml"));
        lblResult.Text = "XML File Created";

        XmlTextWriter xmlWriter 
          = new XmlTextWriter(Server.MapPath("~/DOM/xml/updatedPRODUCT.xml"), null);
        xmlWriter.Formatting = Formatting.Indented;
        xmlWriter.WriteStartDocument();
        xmlWriter.WriteStartElement("PRODUCT");

        /*xmlWriter.WriteStartElement("car");
        xmlWriter.WriteStartElement("MOVIE_NAME");
        xmlWriter.WriteAttributeString("foreign","true");
        xmlWriter.WriteString("Lion King");
        xmlWriter.WriteEndElement(); */       // end <MOVIE>

        xmlWriter.WriteElementString("PRODUCT_NAME", "Lion King");
        xmlWriter.WriteElementString("RELEASE_DATE", "15 June 1994");
        xmlWriter.WriteElementString("ACTOR", "James Earl Jones, Jonathan Taylor Thomas");
        xmlWriter.WriteElementString("DIRECTOR", "Roger Allers, Rob Minkoff");
        xmlWriter.WriteElementString("LANGUAGE", "English");
        xmlWriter.WriteElementString("GENRE", "family");
        xmlWriter.WriteElementString("CATEGORY", "Movie");
        xmlWriter.WriteElementString("RATING", "G");
        xmlWriter.WriteElementString("DISCOUNT", "10% off");
        xmlWriter.WriteElementString("QUANTITY", "20");
        xmlWriter.WriteElementString("PRICE", "$5.00");
        xmlWriter.WriteElementString("MANUFACTURER", "Walt Disney Pictures");
        xmlWriter.WriteElementString("UNTI_WEIGHT", "7.5 ounces");
        xmlWriter.WriteElementString("SHORT_DESCRIPTION", "Young lion cub, Simba, is force to choose between loyalty to his individual self and his pride.");
        xmlWriter.WriteElementString("LONG_DESCRIPTION", "Young lion cub, Simba, is forced from his pride, afer his father his family is torn apart by a tragedy, which causes his pride to erupt in turmoil until he is forced to choose between loyalty to his individual self and his pride.");
        xmlWriter.WriteElementString("KEYWORD_LIST", "lion");
        xmlWriter.WriteElementString("IMAGE_SMALL", "~/Images/LionKingsmall.jpg");
        xmlWriter.WriteElementString("IMAGE_LARGE", "~/Images/LionKinglarge.jpg");

        xmlWriter.WriteEndElement();         // end <PRODUCT>

        /*xmlWriter.WriteStartElement("car");
        xmlWriter.WriteStartElement("make");
        xmlWriter.WriteAttributeString("foreign", "false");
        xmlWriter.WriteString("Ford");
        xmlWriter.WriteEndElement();         // end <make>
        xmlWriter.WriteElementString("model", "F-150");
        xmlWriter.WriteElementString("color", "Blue");
        xmlWriter.WriteElementString("year", "2000");
        xmlWriter.WriteEndElement();         // end <car>
        xmlWriter.WriteEndElement();         // end <cars> */

        xmlWriter.Flush();
        xmlWriter.Close();

        lblResult.Text = "XML written successfully!";
    }

    public void Page_Load(object sender, EventArgs e)
    {
        XmlTextReader xmlReader = new XmlTextReader(Server.MapPath("~/DOM/xml/article.xml"));
        DisplayXML(xmlReader);
        xmlReader.Close();
    }


    public void DisplayXML(XmlTextReader xmlReader)
    {

        while (xmlReader.Read())     // read() for each node
        {
            if (xmlReader.NodeType == XmlNodeType.Element)
            {
                Response.Write("<br>");
                Response.Write("<b>Element: </b>" + xmlReader.Name);
                if (xmlReader.HasAttributes)
                {
                    Response.Write(" <b>Attributes: </b>");
                    for (int attIdx = 0; attIdx < xmlReader.AttributeCount; attIdx++)
                    {
                        //the Item property retrieves the value for each node's attribute
                        Response.Write(xmlReader[attIdx]);
                        if (attIdx < xmlReader.AttributeCount - 1)
                        {
                            Response.Write(", ");
                        }
                    }
                }
            }
            else if (xmlReader.NodeType == XmlNodeType.Text)
            {
                Response.Write(" <b>Value: </b>" + xmlReader.Value);
            }
        }
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Show XML File</title>
</head>
<body>
    <form id="form1" runat="server">

    &nbsp;<div>

    <%--<asp:SqlDataSource
        id="srcProducts"
        DataSourceMode="DataReader"
        SelectCommand="SELECT * FROM PRODUCT"
        ConnectionString="<%$ ConnectionStrings:eBizDatabase %>"
        Runat="server" onselecting="DisplayXML" />--%>

        <asp:SqlDataSource
        id="srcProducts"
        SelectCommand="SELECT * FROM PRODUCT"
        ConnectionString="Data Source=.\SQLExpress;AttachDbFilename=|DataDirectory|MyDatabase.mdf;Integrated Security=True;User Instance=True"
        Runat="server" onselecting="DisplayXML" />

        <br />

    Click the button to generate "PRODUCT.xml"<br/>


 <asp:Button runat="server" id="btnXML" Text="Generate XML" 
                   OnClick="btnXML_Create"/>
 <br/>

    <asp:Label
        id="lblResult" 
        Runat="server" />


        <br />
        <br />


        <br />


        <asp:HyperLink
            id="HyperLink_XML"
            Text="Show Updated XML"
            NavigateUrl='~/WriteXML.aspx'
            runat="server" />

        <br />

    </div>
    </form>
</body>
</html>

This is a problem:

ConnectionString="Data Source=.\SQLExpress;AttachDbFilename=|DataDirectory|MyDatabase.mdf;Integrated Security=True;User Instance=True"

This is not a valid connection string. The |DataDirectory| needs to be replaced with the path to the database directory.

Fixed connectionstring, still getting same error, and there's an error with beginning <script> beginning tag:

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.Adapters" %>
<%@ Import Namespace="System.Web.Services" %>
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.ApplicationServices" %>
<%@ Import Namespace="System.Web.Services.Description" %>


<%--<%@ Import Namespace="System.Web.Handlers" %>
<%@ Import Namespace="System.Web.Compilation" %>
<%@ Import Namespace="System.Web.Query.Dynamic" %>
<%@ Import Namespace="System.Web.Services.Protocols" %>
<%@ Import Namespace="System.Web.UI.WebControls.Expressions" %>
<%@ Import Namespace="System.Web.UI.WebControls.WebParts" %>
<%@ Import Namespace="System.Web.Util" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Collections.Generic" %>--%>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


<script runat="server">

    public void btnXML_Create(object sender, EventArgs e)
    {
        string _conString = srcProducts.ConnectionString;
        string strSQL = "SELECT * FROM PRODUCT";
        DataSet ds = new DataSet("PRODUCT");
        SqlDataAdapter productsSDA = new SqlDataAdapter(strSQL, _conString);
        SqlConnection cn = new SqlConnection(strSQL);
        productsSDA.Fill(ds, "PRODUCT");
        ds.WriteXml(Server.MapPath("~/DOM/xml/movieDb.xml"));
        lblResult.Text = "XML File Created";

        XmlTextWriter xmlWriter 
          = new XmlTextWriter(Server.MapPath("~/DOM/xml/updatedPRODUCT.xml"), null);
        xmlWriter.Formatting = Formatting.Indented;
        xmlWriter.WriteStartDocument();
        xmlWriter.WriteStartElement("PRODUCT");

        xmlWriter.WriteElementString("PRODUCT_NAME", "Lion King");
        xmlWriter.WriteElementString("RELEASE_DATE", "15 June 1994");
        xmlWriter.WriteElementString("ACTOR", "James Earl Jones, Jonathan Taylor Thomas");
        xmlWriter.WriteElementString("DIRECTOR", "Roger Allers, Rob Minkoff");
        xmlWriter.WriteElementString("LANGUAGE", "English");
        xmlWriter.WriteElementString("GENRE", "family");
        xmlWriter.WriteElementString("CATEGORY", "Movie");
        xmlWriter.WriteElementString("RATING", "G");
        xmlWriter.WriteElementString("DISCOUNT", "10% off");
        xmlWriter.WriteElementString("QUANTITY", "20");
        xmlWriter.WriteElementString("PRICE", "$5.00");
        xmlWriter.WriteElementString("MANUFACTURER", "Walt Disney Pictures");
        xmlWriter.WriteElementString("UNTI_WEIGHT", "7.5 ounces");
        xmlWriter.WriteElementString("SHORT_DESCRIPTION", "Young lion cub, Simba, is force to choose between loyalty to his individual self and his pride.");
        xmlWriter.WriteElementString("LONG_DESCRIPTION", "Young lion cub, Simba, is forced from his pride, afer his father his family is torn apart by a tragedy, which causes his pride to erupt in turmoil until he is forced to choose between loyalty to his individual self and his pride.");
        xmlWriter.WriteElementString("KEYWORD_LIST", "lion");
        xmlWriter.WriteElementString("IMAGE_SMALL", "~/Images/LionKingsmall.jpg");
        xmlWriter.WriteElementString("IMAGE_LARGE", "~/Images/LionKinglarge.jpg");
        xmlWriter.WriteEndElement();         // end <PRODUCT>


        xmlWriter.Flush();
        xmlWriter.Close();

        lblResult.Text = "XML written successfully!";
    }

    public void Page_Load(object sender, EventArgs e)
    {
        XmlTextReader xmlReader = new XmlTextReader(Server.MapPath("~/DOM/xml/article.xml"));
        DisplayXML(xmlReader);
        xmlReader.Close();
    }


    public void DisplayXML(XmlTextReader xmlReader)
    {

        while (xmlReader.Read())     // read() for each node
        {
            if (xmlReader.NodeType == XmlNodeType.Element)
            {
                Response.Write("<br>");
                Response.Write("<b>Element: </b>" + xmlReader.Name);
                if (xmlReader.HasAttributes)
                {
                    Response.Write(" <b>Attributes: </b>");
                    for (int attIdx = 0; attIdx < xmlReader.AttributeCount; attIdx++)
                    {
                        //the Item property retrieves the value for each node's attribute
                        Response.Write(xmlReader[attIdx]);
                        if (attIdx < xmlReader.AttributeCount - 1)
                        {
                            Response.Write(", ");
                        }
                    }
                }
            }
            else if (xmlReader.NodeType == XmlNodeType.Text)
            {
                Response.Write(" <b>Value: </b>" + xmlReader.Value);
            }
        }
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Show XML File</title>
</head>
<body>
    <form id="form1" runat="server">

    <div>

    <%--<asp:SqlDataSource
        id="srcProducts"
        DataSourceMode="DataReader"
        SelectCommand="SELECT * FROM PRODUCT"
        ConnectionString="<%$ ConnectionStrings:eBizDatabase %>"
        Runat="server" onselecting="DisplayXML" />--%>

        <asp:SqlDataSource
        id="srcProducts"
        SelectCommand="SELECT * FROM [PRODUCT]"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        Runat="server" onselecting="DisplayXML" />


        <br />

    Click the button to generate "PRODUCT.xml"<br/>


 <asp:Button runat="server" id="btnXML" Text="Generate XML" onclientclick="Creating XML File"
                   OnClick="btnXML_Create"/>
 <br/>

    <asp:Label
        id="lblResult" 
        Runat="server" />


        <br />
        <br />


        <br />


        <asp:HyperLink
            id="HyperLink_XML"
            Text="Show Updated XML"
            NavigateUrl='~/WriteXML.aspx'
            runat="server" />

        <br />

    </div>
    </form>
</body>
</html>

Thanks, for the help.
Figured it out:

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.Adapters" %>
<%@ Import Namespace="System.Web.Services" %>
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.ApplicationServices" %>
<%@ Import Namespace="System.Web.Services.Description" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Text" %>


<!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">

<script runat="server">

    void btnXML_Create(Object sender, EventArgs e)
    {
       /* 
        string _conString = srcProducts.ConnectionString;
        string strSQL = "SELECT * FROM PRODUCT";
        DataSet ds = new DataSet("PRODUCT");
        SqlDataAdapter productsSDA = new SqlDataAdapter(strSQL, _conString);
        //SqlConnection con = new SqlConnection(strSQL);
        productsSDA.Fill(ds, "PRODUCT");
        ds.WriteXml(Server.MapPath("~/DOM/xml/PRODUCT.xml"));
        lblResult.Text = "XML File Created";
        SqlCommand cmd = new SqlCommand();
        //cmd.Connection = con;
        cmd.CommandText = "SELECT * FROM PRODUCT";*/


        // con.Open(); Return DataReader



        XmlTextWriter xmlWriter 
          = new XmlTextWriter(Server.MapPath("~/DOM/xml/PRODUCT.xml"), null);
        xmlWriter.Formatting = Formatting.Indented;
        xmlWriter.WriteStartDocument();
        xmlWriter.WriteStartElement("PRODUCT");

        xmlWriter.WriteElementString("PRODUCT_NAME", "Lion King");
        xmlWriter.WriteElementString("RELEASE_DATE", "15 June 1994");
        xmlWriter.WriteElementString("ACTOR", "James Earl Jones, Jonathan Taylor Thomas");
        xmlWriter.WriteElementString("DIRECTOR", "Roger Allers, Rob Minkoff");
        xmlWriter.WriteElementString("LANGUAGE", "English");
        xmlWriter.WriteElementString("GENRE", "family");
        xmlWriter.WriteElementString("CATEGORY", "Movie");
        xmlWriter.WriteElementString("RATING", "G");
        xmlWriter.WriteElementString("DISCOUNT", "10% off");
        xmlWriter.WriteElementString("QUANTITY", "20");
        xmlWriter.WriteElementString("PRICE", "$5.00");
        xmlWriter.WriteElementString("MANUFACTURER", "Walt Disney Pictures");
        xmlWriter.WriteElementString("UNTI_WEIGHT", "7.5 ounces");
        xmlWriter.WriteElementString("SHORT_DESCRIPTION", "Young lion cub, Simba, is force to choose between loyalty to his individual self and his pride.");
        xmlWriter.WriteElementString("LONG_DESCRIPTION", "Young lion cub, Simba, is forced from his pride, afer his father his family is torn apart by a tragedy, which causes his pride to erupt in turmoil until he is forced to choose between loyalty to his individual self and his pride.");
        xmlWriter.WriteElementString("KEYWORD_LIST", "lion");
        xmlWriter.WriteElementString("IMAGE_SMALL", "~/Images/LionKingsmall.jpg");
        xmlWriter.WriteElementString("IMAGE_LARGE", "~/Images/LionKinglarge.jpg");
        xmlWriter.WriteEndElement();         // end <PRODUCT>


        xmlWriter.Flush();
        xmlWriter.Close();

        lblResult.Text = "XML written successfully!";
    }

    protected void Page_Load(object sender)
    {
        XmlTextReader xmlReader = new XmlTextReader(Server.MapPath("~/DOM/xml/PRODUCT.xml"));
        DisplayXML(xmlReader);
        xmlReader.Close();
    }


    protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {

        }


    protected void DisplayXML(XmlTextReader xmlReader) // SqlDataSourceSelectingEventHandler e
    {

        while (xmlReader.Read())     // read() for each node
        {
            if (xmlReader.NodeType == XmlNodeType.Element)
            {
                Response.Write("<br>");
                Response.Write("<b>Element: </b>" + xmlReader.Name);
                if (xmlReader.HasAttributes)
                {
                    Response.Write(" <b>Attributes: </b>");
                    for (int attIdx = 0; attIdx < xmlReader.AttributeCount; attIdx++)
                    {
                        //the Item property retrieves the value for each node's attribute
                        Response.Write(xmlReader[attIdx]);
                        if (attIdx < xmlReader.AttributeCount - 1)
                        {
                            Response.Write(", ");
                        }
                    }
                }
            }
            else if (xmlReader.NodeType == XmlNodeType.Text)
            {
                Response.Write(" <b>Value: </b>" + xmlReader.Value);
            }
        }
    }


    protected void DisplayXML(object sender, SqlDataSourceSelectingEventArgs e)
    {

    }
</script>

<head id="Head1" runat="server">
    <title>Show XML File</title>
</head>
<body>
    <form id="form1" runat="server">

    <div>
   <%-- 
    <asp:SqlDataSource
        id="srcProducts"
        DataSourceMode="DataReader"
        SelectCommand="SELECT * FROM PRODUCT"
        ConnectionString="<%$ ConnectionStrings:eBizDatabase %>"
        Runat="server" onselecting="DisplayXML" />
--%>
        <br />

    Click the button to generate "PRODUCT.xml"<br/>


 <asp:Button runat="server" id="btnXML" Text="Generate XML" onclientclick="Creating XML File"
                   OnClick="btnXML_Create"/>
 <br/>

    <asp:Label
        id="lblResult" 
        Runat="server" />
  <br />

   <br />

 <input type="submit" name="Button2" value="Save" id="btnSave2" />

        <asp:HyperLink
            id="HyperLink_XML"
            Text="Show XML"
            NavigateUrl="~/DOM/xml/PRODUCT.xml"
            runat="server" />

        <br />
        <br />
        <asp:HyperLink
            id="HyperLink_UpdXML"
            Text="Generate Updated XML"
            NavigateUrl="~/WriteXML.aspx"
            runat="server" />


    </div>
    </form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.