<asp:DataList>里得到数据的另一要求?
<asp:DataList ID= "DataList1 " runat= "server " DataKeyField= "OrderID " DataSourceID= "SqlDataSource1 ">
<ItemTemplate>
OrderID:
<asp:Label ID= "OrderIDLabel " runat= "server " Text= ' <%# Eval( "OrderID ") %> '>
</asp:Label> <br /> <br />
</ItemTemplate>
</asp:DataList>
--------------------
在里面的数据绑定 <%# Eval( "OrderID ") %> 这个!我想得到他的数据
比如我要在DataList里写 <%string str=当前的Eval( "OrderID ")的值%>
我想得到他的值 做别的判断.例.判断他是不是为空 等等!!!
我该 怎样做!
------解决方案--------------------不好意思,打错了
<%if(OrderID= " "){%>
.........
<%}esle{%>
.........
<%}%>
------解决方案--------------------可以用方法返回值
前台aspx
<asp:DataList ID= "DataList1 " runat= "server " DataKeyField= "OrderID " DataSourceID= "SqlDataSource1 ">
<ItemTemplate>
OrderID:
<asp:Label ID= "OrderIDLabel " runat= "server " Text= ' <%# GetOrderID() %> '>
</asp:Label> <br /> <br />
</ItemTemplate>
</asp:DataList>
后台aspx.cs
string str = string.Empty;
protected string GetOrderId()
{
string orderID = "你从数据库来的值 ";
str = orderID;
return orderID;
}