Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have A textbox with PinCode I want is when the pin Code is correct it shows me the address.I am able to do it with the help of button.but I want to Do it without button . I have Seen this in shopping websites. I am not having any idea about this that is why I am not putting any Code.
Posted
Comments
JayantaChatterjee 13-Dec-14 3:02am    
I think you need to check the length of Pin number in textBox1_TextChanged event, if the length is match the length of Pin number length then search and show the address according to that pin number..
Member 11111143 13-Dec-14 3:41am    
yes this I want But I am not able to search for that code
Maciej Los 13-Dec-14 4:48am    
What have you tried? Where are you stuck? What's teh issue?
Member 11111143 13-Dec-14 4:53am    
protected void Consignor_Details_Click(object sender, EventArgs e)
{

SqlCommand cmd = new SqlCommand("select * from Customer_Master where CustomerCode=" + userid, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.ExecuteNonQuery();
con.Close();
DataSet ds = new DataSet();
da.Fill(ds);
Consignor_Code.Text = ds.Tables[0].Rows[3][1].ToString();
Consignor_Name.Text = ds.Tables[0].Rows[4][2].ToString();
Consignor_Address.Text = ds.Tables[0].Rows[0][3].ToString();
Pin_Code.Text = ds.Tables[0].Rows[0][4].ToString();
City.Text = ds.Tables[0].Rows[0][5].ToString();
State.Text = ds.Tables[0].Rows[0][6].ToString();
Phone.Text = ds.Tables[0].Rows[0][7].ToString();
Email_id.Text = ds.Tables[0].Rows[0][8].ToString();

}
I am able to to do it with button. It is A 5 digit no . I want that when I write 5 digits in textbox then it shows me other fields result.
JayantaChatterjee 13-Dec-14 5:01am    
Sorry I'm not getting you..
what do you means "other fields result"?
how do you get the "userid" variable value?
and what is the problem?

1 solution

Double click on your pin code textBox, and type this code:-

C#
protected void Pin_Code_TextChanged(object sender, EventArgs e)
        {
            if (Pin_Code.Text.Length == 5)
            {
               SqlCommand cmd = new SqlCommand("select * from Customer_Master where CustomerCode=" + Pin_Code.Text, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.ExecuteNonQuery();
con.Close();
DataSet ds = new DataSet();
da.Fill(ds);
Consignor_Code.Text = ds.Tables[0].Rows[3][1].ToString();
Consignor_Name.Text = ds.Tables[0].Rows[4][2].ToString();
Consignor_Address.Text = ds.Tables[0].Rows[0][3].ToString();
Pin_Code.Text = ds.Tables[0].Rows[0][4].ToString();
City.Text = ds.Tables[0].Rows[0][5].ToString();
State.Text = ds.Tables[0].Rows[0][6].ToString();
Phone.Text = ds.Tables[0].Rows[0][7].ToString();
Email_id.Text = ds.Tables[0].Rows[0][8].ToString();
            }
        }

You can remove the button..
I hope this will help you..
 
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