Auto Complete

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nilesh810
    New Member
    • Mar 2009
    • 3

    Auto Complete

    I have two tables pre_enquiry & enquiry ,enquiryno is primary key of pre_enquiry table,username is also stored in it.In enquiry webform if i enter username then related enquiryno. should be autofilled in textbox ,& delete the record from pre_enquiry table
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Nilesh810
    I have two tables pre_enquiry & enquiry ,enquiryno is primary key of pre_enquiry table,username is also stored in it.In enquiry webform if i enter username then related enquiryno. should be autofilled in textbox ,& delete the record from pre_enquiry table
    Start your own thread.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by Nilesh810
      I have two tables pre_enquiry & enquiry ,enquiryno is primary key of pre_enquiry table,username is also stored in it.In enquiry webform if i enter username then related enquiryno. should be autofilled in textbox ,& delete the record from pre_enquiry table
      Hi Nilesh,

      What have you tried so far to solve your problem?
      Have you checked out the AutoComplete control available to you for free in the Ajax Tool Kit?

      -Frinny

      Comment

      • Nilesh810
        New Member
        • Mar 2009
        • 3

        #4
        No,I haven't tried it in ajax ,I want to do that in asp.net with c# & sql2005

        Comment

        • Nilesh810
          New Member
          • Mar 2009
          • 3

          #5
          I have done the following
          Code:
          protected void TextBox1_TextChanged(object sender, EventArgs e)
              {   
                where(Uname="+TextBox1.Text+")");
                   int i;
                   cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["BruserConnectionString2"].ConnectionString);
                   cmd = new SqlCommand("select EnquiryNo from Pre_Enquiry where(Uname=@uname);", cn1);
                      cn1.Open();
                      SqlDataReader tr;
                      tr=cmd.ExecuteReader();
                      while (tr.Read()) 
                      {
                          i = Convert.ToInt32(tr["EnquiryNo"]);
                          TxtEnqNo.Text = Convert.ToString(i);
                          //TxtEnqNo.Text=cmd.Parameters.Add("@EnquiryNo").Value;
                      }
                      tr.Close();
                      cn1.Close();
              }
          i want to fetch EnquiryNo from Pre_enq table & assign the value to TxtEnqNo textbox
          Last edited by Frinavale; Mar 10 '09, 01:04 PM. Reason: Added [code] tags: Please post code in [code] [/code] tags

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            You aren't supplying the parameter to the sql command...

            Code:
            protected void TextBox1_TextChanged(object sender, EventArgs e)
                {   
                  where(Uname="+TextBox1.Text+")");
                     int i;
                     cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["BruserConnectionString2"].ConnectionString);
                     cmd = new SqlCommand("select EnquiryNo from Pre_Enquiry where(Uname=@uname);", cn1);
            //Note the following line......
                      cmd.Parameters.Add("@uname", SqlDbType.varChar).Value = TextBox1.Text
                        cn1.Open();
                        SqlDataReader tr;
                        tr=cmd.ExecuteReader();
                        while (tr.Read()) 
                        {
                            i = Convert.ToInt32(tr["EnquiryNo"]);
                            TxtEnqNo.Text = Convert.ToString(i);
                            //TxtEnqNo.Text=cmd.Parameters.Add("@EnquiryNo").Value;
                        }
                        tr.Close();
                        cn1.Close();
                }

            Comment

            Working...