0
我在我的頁面中有五個圖像控制器。我想隱藏圖像控制器,如果他們沒有任何圖像。現在我正在接受像下面給出的。如何隱藏圖像控制器?
代碼:
DataTable dt = new DataTable();
dt = tt.GetImage(Ids);
foreach (DataRow row in dt.Rows)
{
byte[] img1 = (byte[])row["Im1"];
string base1 = Convert.ToBase64String(img1);
Image1.ImageUrl = "data:image/jpg;base64," + base1;
byte[] img2 = (byte[])row["Im2"];
string base2 = Convert.ToBase64String(img2);
Image2.ImageUrl = "data:image/jpg;base64," + base2 ;
byte[] img3 = (byte[])row["Im3"];
string base3 = Convert.ToBase64String(img3);
Image3.ImageUrl = "data:image/jpg;base64," + base3 ;
byte[] img4 = (byte[])row["Im4"];
string base4 = Convert.ToBase64String(img4);
Image4.ImageUrl = "data:image/jpg;base64," + base4 ;
byte[] img5 = (byte[])row["Im5"];
string base5 = Convert.ToBase64String(img5);
Image5.ImageUrl = "data:image/jpg;base64," + base5 ;
}
ASPX:
<asp:Image ID="Image1" runat="server" Width="559px" Height="210px"/>
<br />
<asp:Image ID="Image2" runat="server" Width="559px" Height="210px"/>
<br />
<asp:Image ID="Image3" runat="server" Width="559px" Height="210px"/>
<br />
<asp:Image ID="Image4" runat="server" Width="559px" Height="210px"/>
<br />
<asp:Image ID="Image5" runat="server" Width="559px" Height="210px"/>