后台:
protected void favFolderRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
Repeater favFolderFileRepeater = (Repeater)e.Item.FindControl("favFolderFileRepeater");
System.Data.Common.DbDataRecord newRow = (System.Data.Common.DbDataRecord)e.Item.DataItem;
int parentId = Convert.ToInt32(newRow["this_id"]);
//Response.Write(parentId);
string connStr = ConfigurationManager.AppSettings[0].ToString();
SqlConnection conn = new SqlConnection(connStr);
string cmdStr = "select this_id,this_title,this_url,this_tip,this_color from userFav where this_name = @this_name and
parent_id=@parent_id order by order_id";
SqlCommand comm = new SqlCommand(cmdStr, conn);
comm.Parameters.AddWithValue("@this_name", User.Identity.Name);
comm.Parameters.AddWithValue("@parent_id",parentId);
conn.Open();
SqlDataReader dr = comm.ExecuteReader();
favFolderFileRepeater.DataSource = dr;
favFolderFileRepeater.DataBind();
dr.Close();
conn.Close();
}
前台:
<td width="50%" valign="top" id="folderTd">
<asp:Repeater ID="favFolderRepeater" runat="server" OnItemDataBound="favFolderRepeater_ItemDataBound">
<ItemTemplate>
<div id='<%#"div"+Eval("this_id") %>'><img src="images/folder.gif" alt="" style="border:0px;" /><%#Eval("this_title") %>
<asp:Repeater ID="favFolderFileRepeater" runat="server">
<ItemTemplate>
<div style="margin-left:20px;">
<a id='<%#Eval("this_id") %>' title='<%#Eval("this_tip") %>' target="_blank" href='<%#Eval("this_url") %>' style='height:15;position:relative;color:<%# Eval("this_color") %>' onclick="return this.clickReturnValue;"><%#Eval("this_title") %></a>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:Repeater>
</td>