Wednesday 25 April 2012

image show in div tag from database , fast way to show image in asp.net web page with sql serever database code

image show in div tag from database , fast way to show image in asp.net web page with sql serever database code..................
<div id="members1" runat="server" class="celebs">
                </div>
////------------
    private void getDataMembers()
    {
        string textDisplay = "";
        myConn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
        SqlCommand cmd = new SqlCommand("select top(3)* from Successful_order by newid()", myConn);
        myConn.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        if (dr.HasRows)
        {
            int i = 1; string profile = "";
            textDisplay = "<ul>";
            while (dr.Read())
            {
                if (i > 3) break;
                if (isPremiumMember(dr["userid"].ToString()) == "Premium")
                {
                    profile = "PremiumMembers.aspx?u=" + dr["userid"] + "&c=" + dr["catid"];
                }
                else
                {
                    profile = "profiledetails.aspx?uid=" + dr["userid"] + "&cid=" + dr["catid"];
                }
                textDisplay += "<li><a href='" + profile + "' target='_blank'><img alt='" + dr["name"] + " at Bollywoodhunts.com" + "' src='" + getUserImage(dr["userid"].ToString(), Convert.ToInt32(dr["catid"])) + "' width='128' height='95' //>" + ((dr["Name"].ToString().Length >= 16) ? Utilities.ToPascalCase(dr["Name"].ToString().Substring(0, 16)) + "..." : Utilities.ToPascalCase(dr["Name"].ToString())) + "</a></li>";
               
                i++;
            }
            textDisplay += "</ul>";
        }
        myConn.Close();
        myConn.Dispose();
        members1.InnerHtml = textDisplay;
    }

No comments:

Post a Comment