0

在我的网站中,我使用 html 编辑器将数据保存在 xml 中。当我在内容之前添加图片意味着内容顶部并将其保存在 xml 中时。现在的问题是,当我试图从 xml 获取结果到转发器控件时,内容顶部的图像是给我空白的结果。这是我用于在 xml 中保存数据的代码

    int date = DateTime.Now.Day;
    int month = DateTime.Now.Month;
    int year = DateTime.Now.Year;
    String File = Server.MapPath("~/Data/BlogContent.xml");
       int newid;
        XDocument doc = XDocument.Load(File);
        XElement root = doc.Root;
          string id = root.Elements("post").Last().ToString();
        XmlDocument pacXML = new XmlDocument();
        pacXML.Load(new StringReader(id));
        XmlNode xmlnode1;
        xmlnode1 = pacXML.DocumentElement.ChildNodes.Item(1);
 String stCode = Convert.ToString(pacXML.DocumentElement.ChildNodes.Item(0).InnerText).Trim();
        if (xmlnode1 == null)
        {
            newid = 1;
        }
        newid = Convert.ToInt32(stCode.ToString()) + 1;
        XmlDocument xdoc = new XmlDocument();
        xdoc.Load(File);
        XmlNode xnode = xdoc.SelectSingleNode("content");
        XmlNode xrnode = xnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "post", ""));
        xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "id", "")).InnerText = newid.ToString();
        xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "title", "")).InnerText = TextBox1.Text;
        xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "Discription", "")).InnerText = Editor.Text;
        xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "dt", "")).InnerText = date.ToString();
        xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "mnt", "")).InnerText = month.ToString();
        xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "yr", "")).InnerText = year.ToString();
        xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "PostDate", "")).InnerText = DateTime.Now.ToString("MM/dd/yyyy");
        xdoc.Save(File);
        Editor.Text = string.Empty;
        TextBox1.Text = string.Empty;

它是中继器中显示数据的代码

PagedDataSource page = new PagedDataSource();
        page.AllowCustomPaging = true;
        page.AllowPaging = true;
        DataTable dtv = (DataTable)ViewState["Mytable"];
        DataView dv = new DataView();
        dv = dtv.DefaultView;
        dv.Sort = dtv.Columns["id"].ColumnName;
        dv.Sort += " Desc";
       dv.RowFilter = "id>=" + pageSize + " AND " + "id<=" + take;
        page.DataSource = dv;
        page.PageSize = psize;
        Repeater1.DataSource = page;
        Repeater1.DataBind();
        if (!IsPostBack)
        {
            int rowcount = dtv.Rows.Count;
            CreatePagingControl(rowcount);
        }

这里中继器正在绑定

  <asp:Repeater ID="Repeater1" runat="server" 
            onitemcommand="Repeater1_ItemCommand" 
            onitemdatabound="Repeater1_ItemDataBound1" >

        <ItemTemplate>

      <ul class="articles box">
        <li>
            <asp:Label ID="Label1" runat="server" Text='<%#Eval("id") %>' color="white"></asp:Label>
         <h2><a href='<%# Eval("id","PostComment.aspx?id={0}") %>'> <asp:Label ID="Label3" runat="server" Text='<%#Eval("title ") %>'></asp:Label></a></h2>
             <div class="article-info box">
            <p class="f-right"><a href='<%# Eval("id","PostComment.aspx?id={0}") %>' class="comment"><asp:Label ID="Label4" runat="server" Text="Label"></asp:Label></a></p>
            <p class="f-left"> 
                Post Date:<asp:Label ID="Label2" runat="server" Text='<%#Eval("postdate") %>'></asp:Label>    
          </div>
          <p>             <asp:Label ID="Label5" runat="server" Text="this is the blog of journeycook.com website" Visible="false"></asp:Label>
 <asp:Label ID="lblcontent" runat="server" Text='<%# Limit(Eval("Discription"),1000) %>'></asp:Label></p>
            <p class="more"><asp:HyperLink ID="ReadMoreLinkButton" runat="server" NavigateUrl='<%# Eval("id","~/PostComment.aspx?id={0}") %>'>Read More</asp:HyperLink></p>
           <%-- <asp:LinkButton ID="ReadMoreLinkButton" runat="server"
                Text="Read More"

                 NavigateUrl='<%# Eval("id","~/PostComment.aspx?id={0}") %>'></asp:LinkButton>--%><br /><br /><br />

       </li>
</ul>      

    </ItemTemplate>
        </asp:Repeater>

我希望你明白我的问题是什么

4

0 回答 0