110,567
社区成员
发帖
与我相关
我的任务
分享
<asp:DataList cellpadding="0" cellspacing="0" ID="DataList1" runat="server" DataKeyField="lei_bh" Width="100%"
onitemdatabound="DataList1_ItemDataBound">
<ItemTemplate>
<table border="0" style="border-left:solid 0px #11aadd; border-bottom:solid 1px #11aadd; width:100%" cellpadding="0" cellspacing="0">
<tr>
<td style="background-color:White; width:120px;border-right:solid 1px #11aadd">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("lei_mc") %>'></asp:Label>
</td>
<td style="background-color:White;">
<asp:DataList cellpadding="0" cellspacing="0" ID="DataList2" runat="server" RepeatColumns="4"
RepeatDirection="Horizontal" ShowFooter="False" ShowHeader="False">
<ItemTemplate>
<table border="0" style="width:100%" cellpadding="0" cellspacing="0">
<tr>
<td style="border-left:solid 0px #11aadd; width:160px"><asp:Label ID="Label2" runat="server" Text='<%# Eval("zlei_mc") %>'></asp:Label> <asp:Label ID="Label3" runat="server" Text='<%# Eval("sum") %>'></asp:Label>(<asp:Label ID="Label4" runat="server" Text='<%# Eval("zlei_dw") %>'></asp:Label>)</td>
</tr>
</table>
</ItemTemplate>
<EditItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" Wrap="False" />
<AlternatingItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" Wrap="False" />
<ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" Wrap="False" />
<SelectedItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" Wrap="False" />
</asp:DataList></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class ZBGL_SelectItem : PageBase
{
DB.data db = new DB.data();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataList();
}
}
private void DataList()
{
string sqlstr = "select * from tbl_zblei";
SqlDataReader dr = db.GetDR(sqlstr);
this.DataList1.DataSource = dr;
this.DataList1.DataBind();
}
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
DataList dl = (DataList)e.Item.FindControl("DataList2");
string ID = DataList1.DataKeys[e.Item.ItemIndex].ToString();
string sqlstr3 = "select tbl_zbzlei.zlei_mc,sum([sum]) as sum,tbl_zbzlei.zlei_dw from tbl_kucun left join tbl_zbzlei on tbl_zbzlei.zlei_bh=tbl_kucun.zlei_bh where tbl_zbzlei.lei_bh='" + ID + "' and dwbm=" + "'" + Session["dwbm"].ToString() + "' GROUP BY tbl_zbzlei.zlei_mc,tbl_zbzlei.zlei_dw";
SqlDataReader dr = db.GetDR(sqlstr3);
dl.DataSource = dr;
dl.DataBind();
}
}
//...........
<FooterTemplate>
<div id="div1" runat ="server" style="background-color:#cccccc; height:100px;">
//这里加你需要的内容,文字,图片等等
</div>
</FooterTemplate>
</asp:DataList>
那在后台写方法。。
public string SetText(object o)
{
if(o.ToString()+""=="")
{return "0";}
else
{return o.ToString();}
}
Text='<%# SetText(Eval("zlei_mc")) %>'
Text='<%# Eval("zlei_mc")==null?0:Eval("zlei_mc") %>'