For example: table name as custome
r 1.Customerid
2.customerName
3.Role customer
wil regisert using this fields.
Next They need to fill another table name as apply
1.customerid(Here if customer enter him/her id it should go database)
2.customerName(here name should get fill)
3.product..
How to do this..
Satyapriya NayakPosted Apr 5, 2013, 5:54 AM
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Related_records_textboxes
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from employee where id='" + TextBox1.Text + "'";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
TextBox2.Text = (reader["empname"].ToString());
}
reader.Close();
con.Close();
}
}
}
Pankaj RawatPosted Apr 5, 2013, 3:01 AM
and create textchange event in Textbox.
protected void txtCustomerID_TextChanged(object sender, EventArgs e)
{
int CustomerID= Convert.ToInt32(txtCustomer.Text.Trim());
DataTable dt = new DataTable();
SqlDataReader reader;
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString))
{
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "Select CustomerName from Customer_Detail where CustomerID=@CustomerID";
cmd.Parameters.Add("@CustomerID", System.Data.SqlDbType.Int).Value = CustomerID;
reader = cmd.ExecuteReader();
dt.Load(reader);
conn.Close();
}
if (dt.Rows.Count > 0)
{
txtName.Text = dt.Rows[0][0].ToString();
}
}