DataList 怎么显示从数据库读取并绑定的二进制数据?
从表中读取数据, 然后 绑定 到 DataList
其中有一个字段是 长二进制 数据类型,
怎么在 DataList 中显示吗?
下面的方法不行... 只显示: System.Byte[]
<div class= "text ">
<%# DataBinder.Eval(Container.DataItem, "content ") %>
</div>
详细:
<%@ Page Language= "C# " AutoEventWireup= "True " validateRequest= "false " %>
<%@ import Namespace= "System.Data " %>
<%@ import Namespace= "System.Data.OleDb " %>
<%@ import Namespace= "System.Web.UI.WebControls " %>
<%@ Assembly src= "cs/Pagination.cs " %>
<%@ Reference Control= "ac/sqEditor.ascx " %>
<%@ Reference Control= "ac/sqEditor.ascx " %>
<script runat= "server ">
public string EdRoot = "/sqEditor_DotNet/ ";
public string ReqIdStr = HttpContext.Current.Request.QueryString[ "id "];
public string ReqAidStr = HttpContext.Current.Request.QueryString[ "aid "];
void Page_Load(Object s, EventArgs e)
{
string SqlCnnStr;
SqlCnnStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= "+
@MapPath(EdRoot+ "/data/shawlqiu.mdb ");
string SqlQuery;
SqlQuery = "select * from shawlqiu_ ";
switch(ReqIdStr)
{
case "edit ":
GetEditor( " <b> hello </b> , test this. ", edPlaceHolder, EdRoot+ "ac/sqEditor.ascx ");
break;
case "display ":
SqlQuery+= " where articleid = "+ReqAidStr;
DisplayList(SqlQuery, SqlCnnStr, acDisplayAtDataList);
break;
default:
DisplayList(SqlQuery, SqlCnnStr, acDataList);
break;
}
} // end Page_Load
private void DisplayList(string SqlQuery, string SqlCnnStr, DataList acDataList)
{
Pagination Paged=new Pagination();
Paged.Debug=false; // 是否为调试模式
Paged.DebugLabel=acDebugLabel; // 显示调试信息的 Label
Paged.NavigatorLabel=acPagedLabel; // 显示主导航条的 Label
Paged.DetailsLabel=acPagedDetailsLabel;// 显示分页明细的 Label
Paged.PageSize=20; // 每页大小
Paged.Go(GetDataTable(SqlQuery, SqlCnnStr), acDataList); // 执行分页
Paged=null;
}
private DataTable GetDataTable(string qry, string cnn, string tableName)
{
DataSet ds = new DataSet();
OleDbConnection oCnn = new OleDbConnection(cnn);
OleDbDataAdapter oDa;
oDa = new OleDbDataAdapter(qry, cnn);
oDa.Fill(ds, tableName);
oCnn.Close();
return ds.Tables[tableName];
} // end private void GetData
private DataTable GetDataTable(string qry, string cnn)
{
return GetDataTable(qry, cnn, "dt ");
} // end private void GetData
public void GetEditor(string inti, PlaceHolder edPlaceHolder, string edPath)
{
sqEditor ed = (sqEditor)LoadControl(edPath);
ed.EdRoot = EdRoot;
ed.EdIntiText = inti;
ed.SubmitEventHandler = new EventHandler(Submit);
edPlaceHolder.Controls.Add(ed);
}
public void Submit(Object s, EventArgs e)
{
TextBox edTextBox =
(TextBox)((Button)s).Parent.FindControl( "edTextBox ");
HtmlGenericControl edIntiDiv =
(HtmlGenericControl)((Button)s).Parent.FindControl( "edIntiDiv ");
edIntiDiv.InnerHtml = edTextBox.Text;
if(edTextBox == null) return;
acDebugLabel.Text = edTextBox.Text;
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=utf-8 " />
<title> shawl.qiu template </title>
<style type= "text/css ">
/* <![CDATA[*/
@import " <% Response.Write(EdRoot); %> style/style.css ";
/*]]> */
</style>
</head>
<body>
<div class= "Main ">
<form runat= "server ">
<asp:Label id=acDebugLabel runat=server
/>
<div class= "algc ">
<div class= "pagedList ">
<asp:Label id=acPagedLabel runat=server
/>
</div>
<div class= "pagedDetails ">
<asp:Label id=acPagedDetailsLabel runat=server
/>
</div>
</div>
<div class= "acMain ">
<asp:DataList id= "acDisplayAtDataList "
BorderColor= "black "
CellPadding= "5 "
CellSpacing= "5 "
RepeatDirection= "Vertical "
RepeatLayout= "Flow "
RepeatColumns= "10 "
ShowBorder= "True "
runat= "server ">
<HeaderTemplate>
<ol class= "acOlList ">
</HeaderTemplate>
<HeaderStyle BackColor= "#aaaadd ">
</HeaderStyle>
<AlternatingItemStyle>
</AlternatingItemStyle>
<ItemTemplate>
<li>
<span class= "algr fltr ">
<a href= "?id=edit&aid= <%# DataBinder.Eval(Container.DataItem, "articleid ") %> ">
edit
</a>
</span>
<a href= "?id=display&aid= <%# DataBinder.Eval(Container.DataItem, "articleid ") %> ">
<%# DataBinder.Eval(Container.DataItem, "title ") %>
</a>
<div class= "text ">
<%# DataBinder.Eval(Container.DataItem, "content ") %>
</div>
</li>
</ItemTemplate>
<%--
<SeparatorTemplate>
</SeparatorTemplate>
--%>
<FooterTemplate>
</ol>
</FooterTemplate>
</asp:DataList>
<asp:DataList id= "acDataList "
BorderColor= "black "
CellPadding= "5 "
CellSpacing= "5 "
RepeatDirection= "Vertical "
RepeatLayout= "Flow "
RepeatColumns= "10 "
ShowBorder= "True "
runat= "server ">
<HeaderTemplate>
<ol class= "acOlList ">
</HeaderTemplate>
<HeaderStyle BackColor= "#aaaadd ">
</HeaderStyle>
<AlternatingItemStyle>
</AlternatingItemStyle>
<ItemTemplate>
<li>
<span class= "algr fltr ">
<a href= "?id=edit&aid= <%# DataBinder.Eval(Container.DataItem, "articleid ") %> ">
edit
</a>
</span>
<a href= "?id=display&aid= <%# DataBinder.Eval(Container.DataItem, "articleid ") %> ">
<%# DataBinder.Eval(Container.DataItem, "title ") %>
</a>
</li>
</ItemTemplate>
<%--
<SeparatorTemplate>
</SeparatorTemplate>
--%>
<FooterTemplate>
</ol>
</FooterTemplate>
</asp:DataList>
</div>
<div class= "sqEditorDiv ">
<asp:PlaceHolder id=edPlaceHolder runat=server
/>
</div>
</form>
</div>
<p/> <a href= "? "> --back-- </a>
</body>
</html>
[解决办法]
tolong
up
[解决办法]
是图片信息吗?