可以将表自己进行连接
select a.change_type as a_type,a.product_id as a_product_id,b.change_type as b_type ....from tableA a inner join tableA b on
a.product_id = b.product_id and a.change_type != b.change_type
这样就返回的数据集每行就已经包含了DataList每个Item所需要的所有信息,相信其他的就比较容易了
select a.change_type as a_type,a.product_id as a_product_id,b.change_type as b_type ....from tableA a inner join tableA b on
a.product_id = b.product_id and a.change_type != b.change_type
这样就返回的数据集每行就已经包含了DataList每个Item所需要的所有信息,相信其他的就比较容易了
asp:Repeater在这三个数据绑定控件中是最灵活的一个了,它是我的最爱。呵呵。
我现在手头没有开发环境,只能用手工给你写一个了,我只能说能现实你上面的格式,但不保证单词和语法上的正确性,如果你要用的说可以自己改改喽.
但有个要求:就是要对数据进行处理一下,对用户名列进行排序。
<asp:Repeater runat=server id=test OnItemDataBound=testbinder>
<headerTemplate>
<table width=100%>
</headerTemplate>
<itemTemplate>
<tr runat=server id=windowsboy>
<td width=50% colspan=2>修改人:<%container.evl(dataitem.change_user)%></td>
<td width=50% colspan=2> 修改时间:<%container.evl(dataitem.change_date)%></td>
</tr>
<tr>
<td width=25%>修改类型:<%container.evl(dataitem.chang_type)%></td>
<td width=25%>产品ID:<%container.evl(dataitem.procduct_ID)%></td>
<td width=25%>产品名:<%container.evl(dataitem.procduct_name)%></td>
<td width=25%>产品信息:<%container.evl(dataitem.product_info)%></td>
</tr>
</itemTemplate>
<footerTemplate>
</table>
</footerTemplate>
</asp:Repeater>
上面这些是页面里的。然后是在服务器端写代码了。
public void testbinder(Object Sender, RepeaterItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item|| e.Item.ItemType == ListItemType.AlternatingItem)
{
System.Web.UI.HtmlControls.我忘了 objTR=(System.Web.UI.HtmlControls.我忘了)e.Item.FindControl("windowsboy");//你自己查一下吧。
//这里你要判断“修改人”是不是已经添加过了。如果是则将objTR.Visible=false;
//否则就是一个新的“修改人”了,*这里的前提是你已经对用户名列进行了排序。*
}
}
这样写可以实现你说的那个样子.我开始写的时候认为挺好写的,可是写着写着就变了。比和我最初想像的要难的多了。
这个方法虽然可以实现,但它也不是一个最好的方法,希望你能找以更好的方法。
设置group组为change_user,change_date o