I am trying to populate the fields on a form from the database and the values aren't populating on the form. I have the value for the where clause hard coded in the code and it doesn't show the values that are in the database for that record on the form:
protectedvoid Page_Load(object sender, EventArgs e)
{this.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;
{
labelRID.Text = Request.QueryString["id"];string rid = labelRID.Text;string activityid = labelactivityid.Text;if (!IsPostBack)
{
Bindactivitycodedropdown();if (rid != "")
{
OracleConnection conn = new OracleConnection();
OracleCommand cmd = new OracleCommand();
conn.ConnectionString = strConnection;
conn.Open();
cmd.Connection = conn;
cmd.CommandText = "Select RID, BUYING_ACTIVITY_ID, CUSTOMER_SOURCE_CODE, CUSTOMER_NAME, CUSTOMER_CITY, CUSTOMER_STATE, CUSTOMER_POSTAL_CODE, BUYING_ACTIVITY_CODE from BUYING_ACTIVITY WHERE RID = '55555'";
cmd.Parameters.Add(new OracleParameter("RID", Request.QueryString["ID"]));
OracleDataAdapter da = new OracleDataAdapter(cmd);
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();if (dr.Read())
{
labelRID.Text = dr["rid"].ToString();
custname.Text = dr["customer_name"].ToString();
custcity.Text = dr["customer_city"].ToString();
custstate.Text = dr["customer_state"].ToString();
custpostalcode.Text = dr["customer_postal_code"].ToString();
activitycode.SelectedItem.Text = dr["buying_activity_code"].ToString();
custsrccode.Text = dr["customer_source_code"].ToString();
cvactivitycode.Enabled = false;//custname.Text = custstate.SelectedValue.ToString();//if (activitycode.SelectedValue == "0")//{// custname.Text = "";// custcity.Text = "";// custpostalcode.Text = "";//} dr.Close();
conn.Close();
}else
{
labelRID.Text = "";
custname.Text = "";
custcity.Text = "";
custstate.Text = "";
custpostalcode.Text = "";
activitycode.SelectedItem.Text = "";
custsrccode.Text = "C812 - NASA";
}
}
}
}
}