以下是datalist控件的内容
<asp:DataList ID="dlHotFlower" runat="server" DataSourceID="odsDisplayForIndex" HorizontalAlign="Left"
RepeatColumns="4" style="text-align:center;width:600px;" >
<ItemTemplate>
<asp:Panel ID="pnlFlowerItem" ToolTip="abc" runat="server" style="width:130px;padding:2px;" OnLoad="pnlFlowerItem_OnLoad" >
<ul>
<li style="text-align:center;height:120px;vertical-align:middle;line-height:120px;">
<asp:HyperLink ID="hlFlowerImage" ImageUrl='<%# Eval("ImagePath") %>' Target="_blank" NavigateUrl='<%# Eval("Link") %>' ToolTip='<%# Eval("Huayu") %>' runat="server" />
</li>
<li style="text-align:center;line-height:15px;">
<asp:HyperLink ID="HyperLink1" NavigateUrl='<%# Eval("Link") %>' Target="_blank" runat="server">
<asp:Label ID="lblFlowerUse" Text='<%# Eval("Sort_use") %>' ForeColor="#459700" runat="server"></asp:Label><span style="color:#459700;" >/</span><asp:Label ID="lblFlowerName" Text='<%# Eval("Name") %>' ForeColor="#459700" runat="server"></asp:Label>
</asp:HyperLink>
</li>
<li style="text-align:center;line-height:15px;">
<span >市场价:</span>
<span style="text-decoration:line-through;">¥<asp:Label ID="Label1" Text='<%# Eval("Price_macket") %>' ToolTip="市场价" runat="server"></asp:Label></span>
</li>
<li style="text-align:center;line-height:15px;">
<span >现 价:</span>
<span style="color:Red;">¥<asp:Label ID="lblPrice_fact" ForeColor="red" Text='<%# Eval("Price_fact") %>' ToolTip="现价" runat="server"></asp:Label></span>
</li>
</ul>
</asp:Panel>
</ItemTemplate>
</asp:DataList>
datalist中显示的是多种鲜花的图片及相关信息,我想给其中的子控件pnlFlowerItem加圆角效果(不采用css方式),代码如下所示:
public void pnlFlowerItem_OnLoad(object sender, EventArgs e)
{
AddRoundCornerForPanel(sender as Panel);
}
//给datalist的项加入圆角框
public void AddRoundCornerForPanel(Panel pnl)
{
RoundedCornersExtender rce = new RoundedCornersExtender();
//注意此行
rce.TargetControlID = pnl.ID;
rce.BorderColor = Color.Red;
rce.Corners = BoxCorners.All;
rce.Radius = 8;
//ph为页面中预先定义的,用来加入RoundedCornersExtender
PlaceHolder ph = this.FindControl("ph") as PlaceHolder;
ph.Controls.Add(rce);
}
为何程序运行时,一直提示pnl.ID找不到。换成pnl.ClientID问题依然,请问此处应该如何设置呢?如果只是普通的panel就可以这样动态加入圆角,可datalist中的就不行。请知道的朋友指点一下,小弟急求!非常感谢!