protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (!String.IsNullOrEmpty(Request.QueryString["ApplicationTrackingID"]))
{
GetStatusIDByATID(Convert.ToInt32(Request.QueryString["ApplicationTrackingID"]));
}
}
else
{
Master.SetPreviousPage(Master.GetMain());
applicationTrackingID = Request.QueryString["atid"];
jobTrackingID = Request.QueryString["jtid"];
// Get Application status
int.TryParse(applicationTrackingID, out appTrackingID);
ApplicationSettings applicationStatus = new ApplicationSettings(appTrackingID);
appStatus = applicationStatus.StatusCode; // get the full status code name
// Get Job status
int.TryParse(jobTrackingID, out jobTID);
jobstatus = getJobStatusByJobTrackingId(jobTID);
// Get Statement status using ATID
statementStatus = getStatementStatusByApplicationTrackingID(appTrackingID);
if (applicationTrackingID != null && jobTrackingID == "")
{
txtAppTrackingID_App.Text = applicationTrackingID;
txtAppTrackingID_Stmt.Text = applicationTrackingID;
ddlOldStatus_App.SelectedValue = appStatus.ToUpper();
ddlOldStatus_Stmt.SelectedValue = appStatus.ToUpper();
if (statementStatus != null)
{
ddlOldStatus_Stmt.SelectedValue = statementStatus.ToUpper();
}
}
else if (applicationTrackingID != null && jobTrackingID != null)
{
txtAppTrackingID_App.Text = applicationTrackingID;
txtJobTrackingID_Stmt.Text = jobTrackingID;
txtJobTrackingID_Job.Text = jobTrackingID;
// If the TID has run to job process
if ((jobstatus != "ERROR"))
{
// and is job is not in "ERROR" state
ddlOldStatus_App.SelectedValue = appStatus.ToUpper();
ddlOldStatus_Stmt.SelectedValue = jobstatus.ToUpper();
ddlOldStatus_Job.SelectedValue = jobstatus.ToUpper();
}
else
{
// job is in "ERROR" state
// Old ddls of all are set to the "ERROR" status of the job
ddlOldStatus_App.SelectedValue = jobstatus.ToUpper();
ddlOldStatus_Stmt.SelectedValue = jobstatus.ToUpper();
ddlOldStatus_Job.SelectedValue = jobstatus.ToUpper();
}
}
bindrgJobStatus();
}
}
public void GetStatusIDByATID(int ApplicationTrackingID)
{
using (SqlConnection sqlConnection = UTSqlConnection.GetSQLConnection("DynaBillDB"))
{
sqlConnection.Open();
var sqlCommand = new SqlCommand("GetAppstatusByATID", sqlConnection);
sqlCommand.CommandType = CommandType.StoredProcedure;
SqlParameterCollection parameters = sqlCommand.Parameters;
// Define the parameters used
parameters.Add("@AppTrackingID", SqlDbType.Int).Direction = ParameterDirection.Input;
parameters.Add("@AppStatus", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output;
// Populate the parameters
parameters["@AppTrackingID"].Value = ApplicationTrackingID;
sqlCommand.ExecuteNonQuery();
string output = parameters["@AppStatus"].Value.ToString();
ddlOldStatus_App.SelectedValue = output;
}
ddlOldStatus_App.SelectedValue = "AWAITING_DUPLICATE_FILE";
}
<script type="text/JavaScript" src="Scripts/jquery-2.2.4.mis.js"></script>
<script type="text/javascript">
function GetStatusIDByATID(val) {
$.ajax({
type: "GET",
url: "ChangeProcessStatus.aspx?ApplicationTrackingID=" + val,
contentType: "application/json",
dataType: "json",
Error: function (x, e) {
alert("did not work");
}
});
$('#ddlOldStatus_App').val("AWAITING_DUPLICATE_FILE");
}
</script>
<div class="searchFormNoBox span12">
<span>
<label>App Tracking ID</label>
<asp:TextBox ID="txtAppTrackingID_App" onblur="GetStatusIDByATID(this.value)" AutoPostBack="true" runat="server" Width="100px"></asp:TextBox>
</span>
<span>
<label>Old Status</label>
<asp:DropDownList ID="ddlOldStatus_App" AutoPostBack="true" EnableViewState="true" runat="server" Width="170px">
<asp:ListItem Value="" Selected="True"></asp:ListItem>
<asp:ListItem Value="AWAITING_CONF">AWAITING_CONF</asp:ListItem>
<asp:ListItem Value="AWAITING_DUPLICATE_FILE">AWAITING_DUPLICATE_FILE</asp:ListItem>
<asp:ListItem Value="CANCELLED">CANCELLED</asp:ListItem>
<asp:ListItem Value="COMPLETE">COMPLETE</asp:ListItem>
<asp:ListItem Value="CONFIRM_APPROVED">CONFIRM_APPROVED</asp:ListItem>
<asp:ListItem Value="CONFIRM_REJECTED">CONFIRM_REJECTED</asp:ListItem>
<asp:ListItem Value="COPY_FINISHED">COPY_FINISHED</asp:ListItem>
<asp:ListItem Value="COPY_STARTED">COPY_STARTED</asp:ListItem>
<asp:ListItem Value="DUPLICATE_FILE_APPROVED">DUPLICATE_FILE_APPROVED</asp:ListItem>
<asp:ListItem Value="DUPLICATE_FILE_REJECTED">DUPLICATE_FILE_REJECTED</asp:ListItem>
<asp:ListItem Value="EMAIL_READY">EMAIL_READY</asp:ListItem>
<asp:ListItem Value="EMAIL_COMPLETE">EMAIL_COMPLETE</asp:ListItem>
<asp:ListItem Value="ERROR">ERROR</asp:ListItem>
<asp:ListItem Value="FILE_PROCESSING">FILE_PROCESSING</asp:ListItem>
<asp:ListItem Value="FILE_READY">FILE_READY</asp:ListItem>
<asp:ListItem Value="FILE_RECEIVED">FILE_RECEIVED</asp:ListItem>
<asp:ListItem Value="HOLD">HOLD</asp:ListItem>
<asp:ListItem Value="PROCESSING_APP">PROCESSING_APP</asp:ListItem>
<asp:ListItem Value="PROCESSING_QC">PROCESSING_QC</asp:ListItem>
<asp:ListItem Value="QUICKCHANGE_READY">QUICKCHANGE_READY</asp:ListItem>
<asp:ListItem Value="READY">READY</asp:ListItem>
<asp:ListItem Value="SCHEDULED">SCHEDULED</asp:ListItem>
<asp:ListItem Value="WEBVIEW_READY">WEBVIEW_READY</asp:ListItem>
</asp:DropDownList>
</span>
I'm trying to get the drop down list selected value to be set to a certain value after its corresponding text box has lost focus. I'm not 100% sure what is happening. I know it's running page_load multiple times and in the end it is not setting the selected value.
You may notice, in the snippets of code I posted:
ddlOldStatus_App.SelectedValue = "AWAITING_DUPLICATE_FILE";
That is because I've already confirmed that the selected Value is being updated in the code (hovering over the SelectedValue in visual studio shows its new value changes to what is right of the = sign)
I'm focused on it actually visibly changing on the web page.