我使用 xml 作为文件上传器的数据库。我已经上传了文件并生成了 xml,但是我在创建和“管理”页面时遇到了麻烦,该页面列出了数据库中的所有条目,并为用户提供了删除条目以及为条目添加首字母的选项但这不是我需要帮助的地方。我让 XML 正确显示,但要创建一个删除按钮,我意识到我需要使用<asp:GridView>.
我无法让我的 XML 甚至使用 gridView 显示。我想我有删除按钮的功能,但由于这个问题无法测试。任何帮助将不胜感激。
我的代码:
管理员.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="adminXML" runat="server"  />
    </div>
    </form>
</body>
</html>
resdat.xml
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<resdat>
  <entry>
    <date>SomeDate</date>
    <filename>someFile.jpg</filename>
    <filePath>http://google.com</filePath>
    <initials></initials>
  </entry>
  <entry>
    <date>11-11-2013</date>
    <filename>owl2.jpg</filename>
    <filePath>http://somewebsite.com/data/owl2.jpg</filePath>
    <initials></initials>
  </entry>
  <entry>
    <date>11-11-2013</date>
    <filename>wildtextures-old-paper-texture-3.jpg</filename>
    <filePath>http://somewebsite.com/data/wildtextures-old-paper-texture-3.jpg</filePath>
    <initials></initials>
  </entry>
  <entry>
    <date>11-11-2013</date>
    <filename>QwbRElE_.m4a</filename>
    <filePath>http://somewebsite.com/data/QwbRElE_.m4a</filePath>
    <initials></initials>
  </entry>
</resdat>
管理员.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
using System.Linq;
namespace fileUploader
{
    public partial class admin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            XmlDataSource xmlDS = new XmlDataSource();
            xmlDS.EnableCaching = false;
            xmlDS.DataFile = "~/App_Data/resdat.xml";
            xmlDS.TransformFile = "~/App_Data/adminFormat.xslt";
            xmlDS.XPath = "/resdat";
            adminXML.DataSource = xmlDS;
            adminXML.DataBind();
            adminXML.Visible = true;
        }
        private void btn_Delete(object sender, EventArgs e)
        {
            //XmlDocument resdat = new XmlDocument();
            //resdat.Load("~/App_Data/resdat.xml");
            //    resdat.Save(Server.MapPath("~/App_Data/resdat.xml"));
        }
    }
}
adminFormat.xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="html" indent="yes"/>
<!-- This is old code for the <asp:Xml> format -->
    <!--<xsl:template match="/resdat">
        <h3>Entries in XML Database</h3>
      <table>
        <thead>
          <tr>
            <td>Date</td>
            <td>File</td>
            <td>Initials</td>
            <td>Delete</td>
          </tr>
        </thead>
        <xsl:for-each select="entry">
          <tr>
            <td>
              <xsl:value-of select="date"/>
            </td>
            <td>
              <a>
                <xsl:attribute name="href">
                  <xsl:value-of select="filePath"/>
                </xsl:attribute>
                <xsl:value-of select="filename"/>
              </a>
            </td>
            <td>
              <xsl:value-of select="initials"/>
            </td>
            <td>
              <input type="button" value="delete" onClick="btn_Delete" >
                <xsl:attribute name="id">
                  <xsl:value-of select="filename"/>
                </xsl:attribute>
              </input>
            </td>
          </tr>
        </xsl:for-each>
      </table>
    </xsl:template>-->
  <xsl:template match="/">
    <resdat>
      <xsl:apply-templates/>
    </resdat>
  </xsl:template>
  <xsl:template match="entry">
    <entry>
      <xsl:apply-templates select="*"/>      
    </entry>   
  </xsl:template>
  <xsl:template match="resdat/entry/*">
    <xsl:attribute name="{local-name()}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>
</xsl:stylesheet>
我在网上到处搜寻,到目前为止找不到任何适合我的资源。任何帮助将不胜感激。
tl:dr 需要在表格格式的每个“条目”旁边有一个删除按钮。找不到删除按钮的好解决方案/无法将 xml 正确加载到数据网格中。任何帮助表示赞赏。