<li>
<asp:Panel ID="Panel6" runat="server">
<ul id="list2a" runat="server">
</ul>
</asp:Panel>
</li>
<li>
<asp:Panel ID="Panel7" runat="server">
<ul id="list2b" runat="server">
<%--<li><a href="#">
<img src="images/img.gif" width="80" height="80" alt="image description" />
<span class="mask"> </span>
</a></li>
<li><a href="#">
<img src="images/img.gif" width="80" height="80" alt="image description" />
<span class="mask"> </span>
</a></li>
<li><a href="#">
<img src="images/img.gif" width="80" height="80" alt="image description" />
<span class="mask"> </span>
</a></li>--%>
</ul>
</asp:Panel>
</li>
我想在面板內動態添加圖像,然後進入ul,但我需要在一個面板中添加3個圖像,在另一個面板中添加下3個圖像。在asp.net中動態生成圖像?
我後面的代碼如下:
string query2 = "SELECT [Pic_square] From [User1] WHERE ([FB_Id] IN (SELECT [Fb_Id2] FROM [Snapshot] WHERE [Fb_Id1]= '812534558' AND [Seeltr]='See Later')) UNION SELECT [Pic_square] From [Passive] WHERE ([FB_Id] IN (SELECT [Fb_Id2] FROM [Snapshot] WHERE [Fb_Id1]= '812534558' AND [Seeltr]='See Later'))";
var adt = new SqlDataAdapter(query2, con);
ds1 = new DataSet();
adt.Fill(ds1);
int count1 = ds1.Tables[0].Rows.Count;
for (int j = 0; j < count1; j++)
{
HtmlGenericControl listitem1 = new HtmlGenericControl("li");
HtmlGenericControl anchor1 = new HtmlGenericControl("a");
Image im1 = new Image();
im1.ImageUrl = (string)ds1.Tables[0].Rows[j].ItemArray[0];
im1.Height = 80;
im1.Width = 80;
anchor1.Controls.Add(im1);
//anchor1.Attributes.CssStyle.Add("div", "holder");
listitem1.Controls.Add(anchor1);
if(count1 <= 3)
{
list2a.Controls.Add(listitem1);
Panel6.Controls.Add(list2a);
}
else if (3 < count1 && count1 <= 6)
{
list2b.Controls.Add(listitem1);
Panel7.Controls.Add(list2b);
}
else if (6 < count1 && count1 <= 9)
{
//list2b.Controls.Add(listitem1);
list2c.Controls.Add(listitem1);
Panel8.Controls.Add(list2c);
}
else if (9 < count1 && count1 <= 12)
{
list2d.Controls.Add(listitem1);
Panel9.Controls.Add(list2d);
// list2b.Controls.Add(listitem1);
// list2c.Controls.Add(listitem1);
}
else
{
// list2b.Controls.Add(listitem1);
//list2c.Controls.Add(listitem1);
//list2d.Controls.Add(listitem1);
list2e.Controls.Add(listitem1);
Panel10.Controls.Add(list2e);
}
但我得到的6張照片一起,我不想
編輯:PS我有高達10板,我已經加入代碼
請幫忙?
怎麼會變成這樣解決我的問題,如果我有更換面板數量說10我有我的情況 – vini 2012-04-03 08:39:49
@Vini你原來的問題有2個面板 – Pankaj 2012-04-03 08:44:31
是的,我知道我沒有把它放在代碼變得非常大 – vini 2012-04-03 08:46:23