How to convert a label control to Image control?
<p>In a datalist with templates I have 3 labels to store( firstname , scraps ,postedtime), image to store  profile pic and one more image control to store a image in user posted a image as scrap. Now I want this image control visible only when user posted a image otherwise that row to invisible.</p>

<p>code is</p>

<pre><code>        protected void postscrap_Click(object sender, EventArgs e)
       { 
         SqlConnection con = new SqlConnection();  
          con.ConnectionString=ConnectionStrings["Con"].ConnectionString;
             con.Open();

    DataTable dt2 = new DataTable();


     if (con.State == ConnectionState.Open)

    {

   SqlCommand cmd = new SqlCommand();

    cmd.CommandText = "Insert into Scraps(Emailscrapto,scrap,posttime) Values('" +    Session["UserName"].ToString() + "','" + TextBox2.Text.ToString() + "','" + DateTime.Now.ToString() + "')";

        cmd.Connection = con;

        cmd.CommandType = CommandType.Text;

        cmd.ExecuteNonQuery();

        Response.Redirect("UserHome.aspx");

        TextBox2.Text = "";

        SqlDataAdapter d1 = new SqlDataAdapter(" Select * from Login l  Inner  join    Scraps s  on l.Email = s.Email  Where l.Email = '" + Session["UserName"] + "'", con);

        d1.Fill(dt2);

        DataList1.DataSource = dt2;

        DataList1.DataBind();

        con.Close();
    }

    if (dt2.Rows.Count &gt; 0)
    {
        TextBox2.Text = "";
    }
   protected void postimg_Click(object sender, EventArgs e)
      {
    string ToSaveImageName;
    string sImageFileExtension;

    if (FileUpload1.PostedFile != null)
    {
        //Image postedimage = e.FindControl("postedimage");
        //postedimage.Visible = true;
        string myMap = MapPath("~/").ToLower();
        Random r = new Random();
        int next = r.Next();
        string ImageName = FileUpload1.PostedFile.FileName;
        sImageFileExtension = ImageName.Substring(ImageName.LastIndexOf(".")).ToLower();
        SqlConnection con = new SqlConnection();
        con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ConnectionString;
        con.Open();

        DataTable dt2 = new DataTable();

        if (con.State == ConnectionState.Open)

        {
            SqlCommand cmd = new SqlCommand();
            if (sImageFileExtension == ".gif" || sImageFileExtension == ".png" || sImageFileExtension == ".jpg" || sImageFileExtension == ".jpeg" || sImageFileExtension == ".bmp")
            {
                string ImageSaveURL = myMap + "Postedimages/"+next+sImageFileExtension;
               FileUpload1.PostedFile.SaveAs(ImageSaveURL);
                cmd.CommandText = "Insert into Scraps(Emailscrapto,scrap,posttime) Values('" + Session["UserName"].ToString() + "','" + next + sImageFileExtension + "','" + DateTime.Now.ToString() + "')";
                cmd.Connection = con;
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
                Response.Redirect("UserHome.aspx");
            }
        }
    }
}
 protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
   if (e.Item.ItemType == ListItemType.Item ||
     e.Item.ItemType == ListItemType.AlternatingItem)
    {  if (FileUpload1.HasFile != null)
        {
            Image postedimage = (Image)e.Item.FindControl("postedimage");
            postedimage.Visible = true;
        }
    }
}
</code></pre>

<p>the design source is like this</p>

<pre><code>    &lt;asp:DataList ID="DataList1" runat="server" CellPadding="4" Font-Bold="True" Font-     Italic="False"
                Font-Names="Verdana" Font-Overline="False" Font-Size="Medium" Font-Strikeout="False"
                Font-Underline="False" ForeColor="#333333" OnSelectedIndexChanged="DataList1_SelectedIndexChanged"
                Height="1592px" RepeatLayout="Flow" DataSourceID="SqlDataSource1" OnItemCommand="DataList1_ItemCommand"
                OnEditCommand="DataList1_EditCommand" OnItemDataBound="DataList1_ItemDataBound"&gt;
                &lt;AlternatingItemStyle BackColor="White" /&gt;
                &lt;FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
                &lt;FooterTemplate&gt;
                    &lt;asp:TextBox ID="txtcomment" runat="server" Height="29px" Width="188px"&gt;&lt;/asp:TextBox&gt;
                    &amp;nbsp;&lt;br /&gt;
                    &lt;br /&gt;
                    &lt;asp:Button ID="Insert" runat="server" Text="Insert" OnClick="Insert_Click" /&gt;
                &lt;/FooterTemplate&gt;
                &lt;HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
                &lt;ItemStyle BackColor="#FFFBD6" ForeColor="#333333" /&gt;
                &lt;ItemTemplate&gt;
                    &lt;table class="style8"&gt;
                        &lt;tr&gt;
                            &lt;td bgcolor="#FFFF99" class="style12"&gt;
                                &lt;asp:Label ID="Label4" runat="server" Text='&lt;%# Eval("FirstName") %&gt;' Font-Bold="True"
                                    Font-Italic="True" ForeColor="Red"&gt;&lt;/asp:Label&gt;
                            &lt;/td&gt;
                            &lt;td bgcolor="#FFFF99" class="style11"&gt;
                                &lt;asp:Image ID="Image3" runat="server" Height="108px" ImageUrl='&lt;%# "~/UserImage/" +Eval("profile_pic") %&gt;'
                                    Width="98px" /&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                            &lt;td colspan="2" bgcolor="#CCFF99"&gt;
                                &lt;asp:Label ID="Label5" runat="server" Text='&lt;%# Eval("scrap") %&gt;' ForeColor="#000066"&gt;&lt;/asp:Label&gt;
                                &amp;nbsp;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                            &lt;td bgcolor="#CCFF99" colspan="2"&gt;
                                &lt;asp:Image ID="postedimage" runat="server" Height="202px" ImageUrl='&lt;%# "~/Postedimages/" +Eval("scrap") %&gt;'
                                    Visible="False" Width="262px" /&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                            &lt;td class="style13" bgcolor="#FFC1B3"&gt;
                                &lt;asp:LinkButton ID="Edit" runat="server" CommandName="Edit"&gt;Edit&lt;/asp:LinkButton&gt;
                            &lt;/td&gt;
                            &lt;td bgcolor="#FFC1B3"&gt;
                                &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                            &lt;td bgcolor="#CABAF8" class="style13" colspan="2"&gt;
                                &amp;nbsp;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                    &lt;/table&gt;
                    &amp;nbsp;&amp;nbsp;
                &lt;/ItemTemplate&gt;
                &lt;EditItemTemplate&gt;
                    &lt;table class="style14"&gt;
                        &lt;tr&gt;
                            &lt;td bgcolor="#E3ACC8"&gt;
                                &lt;asp:LinkButton ID="cmnt2" runat="server" CommandName="Comment"&gt;Comment&lt;/asp:LinkButton&gt;
                                &amp;nbsp;&amp;nbsp;
                                &lt;asp:LinkButton ID="cancel" runat="server" CommandName="Cancel"&gt;Cancel&lt;/asp:LinkButton&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                            &lt;td bgcolor="#CCFFFF"&gt;
                                &lt;asp:TextBox ID="TextBox3" runat="server" BorderColor="#003300" BorderStyle="Inset"
                                    Height="30px" Width="486px"&gt;&lt;/asp:TextBox&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                    &lt;/table&gt;
                    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                    &lt;br /&gt;
                &lt;/EditItemTemplate&gt;
                &lt;SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" /&gt;
                &lt;SeparatorStyle BackColor="Yellow" Font-Bold="False" Font-Italic="False" Font-Overline="False"
                    Font-Size="Small" Font-Strikeout="False" Font-Underline="False" ForeColor="Maroon"
                    HorizontalAlign="Center" /&gt;
            &lt;/asp:DataList&gt;
</code></pre>

<p>Initially, I made the value of postedimage.visible=false;
but due to the above coding the blank image row is appearing.</p>
