Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to bind image autoextender iam using this code

JavaScript
<script type = "text/javascript">
     function Employees_Populated(sender, e) {
         var employees = sender.get_completionList().childNodes;
         for (var i = 0; i < employees.length; i++) {
             var div = document.createElement("DIV");
             div.innerHTML = "<img style = 'height:50px;width:50px' src = '~Chrysanthemum.jpg/"
        + employees[i]._value + ".jpg' /><br />";
             employees[i].appendChild(div);
         }
     }
     function OnEmployeeSelected(source, eventArgs) {
         var idx = source._selectIndex;
         var employees = source.get_completionList().childNodes;
         var value = employees[idx]._value;
         var text = employees[idx].firstChild.nodeValue;
         source.get_element().value = text;
     }
</script>

C#
[System.Web.Script.Services.ScriptMethod()]
    [System.Web.Services.WebMethod]
    public static List<string> SearchEmployees(string prefixText, int count)
    {
        using (SqlConnection conn = new SqlConnection())
        {
            conn.ConnectionString = ConfigurationManager
                    .ConnectionStrings["GHISConnectionString"].ConnectionString;
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = "select photo, FirstName,LastName, RegistrationNo from" +
                 " PatientRegistration where FirstName like @SearchText + '%'";
                cmd.Parameters.AddWithValue("@SearchText", prefixText);
                cmd.Connection = conn;
                conn.Open();
                List<string> employees = new List<string>();
                using (SqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        employees.Add(AjaxControlToolkit.AutoCompleteExtender
                           .CreateAutoCompleteItem(string.Format("{0} {1} {2}",
                           sdr["FirstName"], sdr["LastName"], sdr["photo"]),
                           sdr["photo"].ToString()));                                                
                    }
                }
                conn.Close();
                return employees;
            }
        }
        
                
    }</string></string></string>
Posted
Updated 21-Feb-14 1:42am
v3
Comments
Krunal Rohit 21-Feb-14 7:22am    
with what ?
-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900