Click here to Skip to main content
16,015,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a textbox with uid when i enter a one number showing the list what i have in the sqlserver database without using ajax,jQuery, only using asp.net,C# please anyone can help...

I'm writing a code under page load..

C#
protected void Page_Load(object sender, EventArgs e)
    {
        string keyword = Request["k"];
        string Mode = Request["Mode"];
        string ReturnTextbox = Request["TB"];
        string MyDiv = Request["MyDiv"];
        if (keyword != null && Mode != null && keyword.Trim().Length > 0)
        {
            string sql = "";
            if (Mode == "uid")
            {
                sql = "SELECT Distinct TOP 5 uid FROM tbuser ORDER BY uid";
            }
            else
            {
                return;
            }
            DataSet ds = new DataSet();
            SqlConnection conn = new SqlConnection();
            conn = new SqlConnection(ConfigurationManager.ConnectionStrings["kuviConnectionString"].ConnectionString);

            SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
           
            adapter.Fill(ds); 
            if (ds != null && ds.Tables.Count > 0)
            {
                DataTable dt = new DataTable();
                dt = ds.Tables[0]; 

                foreach (DataRow row in dt.Rows)
                {
                    string mydata = row[0].ToString(); 
                    if (ReturnTextbox != null && ReturnTextbox.Trim().Length > 0)
                    {

                        //Write to default page, with selection options.
                        if (MyDiv == null || MyDiv.Trim().Length == 0)
                        {
                            Response.Write("<div önmouseover="\" this.style.cursor="pointer" pointer=" mode=" hold=" />                                " önclick="\" mydata="" mydiv=""><font size="2" face="Tahoma">" + mydata + "</font>" + "");
                        }
                    }
                    else
                    {
                        Response.Write("<div><font size="2" face="Tahoma">" + mydata + "</font></div>");
                    }
                }
            }
        }
    }
Posted
Updated 5-Dec-12 21:13pm
v4

 
Share this answer
 

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