不知道你在DataGrid里用不用<%#DataBinder.Eval(Container.DataItem,"xxx")%>如果用的话,你可以参考我的一个问题...http://expert.csdn.net/Expert/topic/1778/1778484.xml?temp=.322201
解决方案 »
- SqlServer中return和output都能返回值,他两在使用上有什么区别!
- asp.net在超链接onclick调用js事件提交怎么才能到后台啊
- 关于ASP.NET调用C++ DLL(含指针)
- 新做的网站,大家帮忙来把把脉!
- ASP.NET中button 的 onCommand传递参数
- 这段代码会不会多此一举?
- 如何定义web自定义控件里的事件(非用户控件),解决马上给分
- 了解深圳富士康的人请进!
- 多维数组排序问题
- 在TreeView中可不可以加入其他的控件,比如文本框?
- 请问大家,HtmLinputfile控件可以保存到网络服务器上吗?
- 有人有ASP.NET Documentation Tool的注册码吗??
http://expert.csdn.net/Expert/topic/1721/1721148.xml?temp=.6977808
上面有怎么用模板列来显示数据源的bool型数据的例子,介绍了好几种方法,有种方法就是你要的,到原文的网站可以下载示例源码。
select '<img src=imgView.aspx?id='+picID+'>' from table2
imgView为图片显示文件.
我看了,大虾的项目总结,但是还是没有解决问题,大虾可否给个具体的例子啊?
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %><html>
<title>Adapting to Data - Images</title>
<style>
hr {height:2px;color:black;}
.StdText {font-family:verdana;font-size:9pt;font-weight:bold;}
.StdTextBox {font-family:verdana;font-size:9pt;border:solid 1px black;filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true');}
.Shadow {filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true');}
</style>
<script runat="server">
public void Page_Load(Object sender, EventArgs e)
{
// Initialize only the first time...
if (!Page.IsPostBack)
{
lblURL.Text = Request.Url + "<hr>";
}
}public void OnLoadData(Object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(txtConn.Text);
SqlDataAdapter da = new SqlDataAdapter(txtCommand.Text, conn);
DataSet ds = new DataSet();
da.Fill(ds, "MyTable"); // Bind the data
grid.DataSource = ds.Tables["MyTable"]; // Display the data
grid.DataBind();
}String GetProperGifFile(int bossID)
{
if (bossID != 0)
return "checked.gif";
return "unchecked.gif";
}</script>
<body bgcolor="ivory" style="font-family:arial;font-size:9pt"><!-- ASP.NET topbar -->
<h2>Adapting to Data - Images</h2>
<asp:Label runat="server" cssclass="StdText" font-bold="true">Current path: </asp:label>
<asp:Label runat="server" id="lblURL" cssclass="StdText" style="color:blue"></asp:label><form runat="server"> <table>
<tr>
<td><asp:label runat="server" text="Connection String" cssclass="StdText" /></td>
<td><asp:textbox runat="server" id="txtConn"
Enabled="false"
cssclass="StdTextBox"
width="700px"
text="DATABASE=Northwind;SERVER=localhost;UID=sa;PWD=;" /></td></tr> <tr>
<td><asp:label runat="server" text="Command Text" cssclass="StdText"/></td>
<td><asp:textbox runat="server" id="txtCommand"
Enabled="false"
width="700px"
cssclass="StdTextBox"
text="SELECT employeeid, titleofcourtesy, firstname, lastname, title, ISNULL(reportsto,0) AS boss FROM Employees" /></td></tr></table> <br><br>
<asp:linkbutton runat="server" id="btnLoad" text="Go get data..." onclick="OnLoadData" /> <hr> <asp:DataGrid id="grid" runat="server"
AutoGenerateColumns="false"
CssClass="Shadow" BackColor="white"
CellPadding="2" CellSpacing="0"
BorderStyle="solid" BorderColor="black" BorderWidth="1"
font-size="x-small" font-names="verdana"> <AlternatingItemStyle BackColor="palegoldenrod" />
<ItemStyle BackColor="beige" />
<HeaderStyle ForeColor="white" BackColor="brown" Font-Bold="true" /> <columns>
<asp:BoundColumn runat="server" HeaderText="ID" DataField="employeeid">
<itemstyle backcolor="lightblue" font-bold="true" />
</asp:BoundColumn> <asp:TemplateColumn runat="server" HeaderText="Employee Name">
<itemtemplate>
<asp:label runat="server"
style="margin-left:5;margin-right:5"
Text='<%# DataBinder.Eval(Container.DataItem, "TitleOfCourtesy") + "<b> " +
DataBinder.Eval(Container.DataItem, "LastName") + "</b>" + ", " +
DataBinder.Eval(Container.DataItem, "FirstName") %>' />
</itemtemplate>
</asp:TemplateColumn> <asp:TemplateColumn HeaderText="Reports"
headerstyle-horizontalalign="Center"
itemstyle-horizontalalign="Center">
<itemtemplate>
<asp:image runat="server"
imageurl='<%# GetProperGifFile((int)DataBinder.Eval(Container.DataItem, "boss")) %>' />
</itemtemplate>
</asp:TemplateColumn> <asp:BoundColumn runat="server" DataField="title" HeaderText="Position" />
</columns>
</asp:DataGrid></form></body>
</html>
大虾真是一个好人!
我本想获取一片树叶,而你却给了我整个森林!
我本想获得一点雨露,而你却给了我整个海洋!
我本想享受一下阳光,而你却给了我整个夏天!
啊,好人!我衷心的祝福你!
我深情的呼唤你!
我把你留在我的记忆里!
哈哈!马上结帖!