分组到是好办,主要绑定问题1.将分组的数据分别存为两个表,然后绑定.
2.返回整个分组数据,然后在控件绑定时控制(itemBound事件中,保存当前行的时间,然后在下次绑定是判断,如果一样则不输出[1999年发布的文件 ],不一样输出).
2.返回整个分组数据,然后在控件绑定时控制(itemBound事件中,保存当前行的时间,然后在下次绑定是判断,如果一样则不输出[1999年发布的文件 ],不一样输出).
调试欢乐多
URL:http://www.cnblogs.com/singlepine/archive/2007/06/01/365964.html
<div>
<asp:DataList runat="server" Id="dlCategories" GridLines="Both" Bordercolor="black" cellpadding="3"
cellspacing="0" Headerstyle-BackColor="#DDDDDD" Headerstyle-Forecolor="#777777" Headerstyle-Font-Name="Arial"
Headerstyle-Font-Size="14" Headerstyle-Font-Bold="true" Font-Name="Arial" Font-Bold="true"
Font-Italic="true" Font-Size="11" ForeColor="Red" RepeatColumns="1" >
<HeaderTemplate>
时间
</HeaderTemplate>
<ItemTemplate>
时间<%# Eval("addtime") %>
<br>
<asp:DataList runat="server" Id="ChildDataList" GridLines="horizontal" Bordercolor="black" cellpadding="3" cellspacing="0" Headerstyle-BackColor="#8080C0" Headerstyle-Font-Name="Arial" Headerstyle-Font-Size="8" Font-Name="Arial" Font-Size="8" datasource='<%# Eval("myrelation") %>' >
<ItemTemplate>
<table >
<tr>
<td><%#Eval("id") %></td>
<td><%#Eval("name") %></td>
<td><%#Eval("time")%></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList> </div>
</form>
protected void Page_Load(object sender, EventArgs e)
{
BindData();
}
void BindData()
{
string conStr = ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(conStr);
DataSet ds = new DataSet();
SqlDataAdapter dpter = new SqlDataAdapter("select distinct addtime from fileInfo", con);
dpter.Fill(ds, "fileInfo_time");
SqlDataAdapter dtper2 = new SqlDataAdapter("select id,name,addtime as time from fileInfo ", con);
dtper2.Fill(ds, "subItem");
ds.Relations.Add("myrelation", ds.Tables["fileInfo_time"].Columns["addtime"], ds.Tables["subItem"].Columns["time"]);
//this.gridview1.datasource = ds.tables[0];
//this.gridview1.databind();
this.dlCategories.DataSource = ds.Tables["fileInfo_time"].DefaultView;
this.dlCategories.DataBind();
}