i am retrieving data into textbox, now i want when data called into textbox then auto insert into gridview.
protected void btnClear_Click(object sender, EventArgs e)
{
insertintopacktxt();
}
private void insertintopacktxt()
{
String strQuery = "select MAX(PID) as PID from tbl_BalPacM" ;
// SqlConnection con = new SqlConnection();
SqlCommand cmde = new SqlCommand();
cmde.Parameters.AddWithValue("@PID", txtsearcbn.Text);
cmde.CommandType = CommandType.Text;
cmde.CommandText = strQuery;
cmde.Connection = con;
try
{
con.Open();
SqlDataReader sdr = cmde.ExecuteReader();
while (sdr.Read())
{
txtsearcbn.Text = sdr["PID"].ToString();
}
}
catch (Exception ex)
{
//throw ex;
}
con.Close();
}
}