日期:2014-05-17 浏览次数:20416 次
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; int index = dataItem.DisplayIndex; DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("msg.xml"));//未处理的“System.StackOverflowException”类型的异常出现在 mscorlib.dll rowdata = ds.Tables[0].Rows[index]["staff"].ToString(); if (rowdata.Length > 0) { int length = rowdata.Length - 1; rowdata = rowdata.Substring(0, length); //HyperLink hyperlink1 = (HyperLink)e.Item.FindControl("HyperLink1"); //HyperLink hyperlink1 = new HyperLink(); Panel panel = (Panel)dataItem.FindControl("panel1"); string[] files = rowdata.Split('#'); int L = files.Length; for (int i = 0; i < L; i++) { string[] filename = files[i].Split('@'); //Response.Write(filename[0]); HyperLink hyperlink1 = new HyperLink(); hyperlink1.NavigateUrl = "usersUpload/" + filename[0]; //Response.Write(filename[0]); hyperlink1.Text = "<img alt='附件:'src='image/zip.jpg' style='border:0px;' /> " + filename[0] + "<br/>"; hyperlink1.ID = "file"; panel.Controls.Add(hyperlink1); //hyperlink1.Text = hyperlink1.Text+ filename[0] ; } //Response.Write(files[3]); //hyperlink1.Text = test; } bindGrid(); } public void bindGrid() { DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("msg.xml")); if (ds.Tables.Count != 0) { ListView1.DataSource = ds.Tables[0]; ListView1.DataBind(); ds.Dispose(); Label1.Visible = false; } else { Label1.Visible = true; } }