asked on
protected void ddlSelectDistributor_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList mySD = (DropDownList)FormView1.FindControl("ddlSelectDistributor");
DropDownList myDist = (DropDownList)FormView1.FindControl("ddlDistributor");
SqlDataSource sqlDist = (SqlDataSource)FormView1.FindControl("sqlDistributors");
if (mySD.SelectedValue == "1144")
{
sqlDist.SelectCommand="SELECT CUSTOMER_NUMBER + '-' + LOCATION AS CUSTOMER_NUM, CUSTOMER_NAME + ' - ' + CASE SYS_STATE WHEN ' ' THEN SYS_PROVINCE ELSE SYS_STATE END + ' ' + SYS_POSTAL_CODE + ' - ' + SYS_ADDRESS_1 AS Location FROM VW_CUSTOMER_ADDRESSES WHERE (CUSTOMER_NUMBER = '1144') ORDER BY CUSTOMER_NUMBER, LOCATION";
myDist.DataBind();
}
if (mySD.SelectedValue == "2335")
{
sqlDist.SelectCommand="SELECT CUSTOMER_NUMBER + '-' + LOCATION AS CUSTOMER_NUM, CUSTOMER_NAME + ' - ' + CASE SYS_STATE WHEN ' ' THEN SYS_PROVINCE ELSE SYS_STATE END + ' ' + SYS_POSTAL_CODE + ' - ' + SYS_ADDRESS_1 AS Location FROM VW_CUSTOMER_ADDRESSES WHERE (CUSTOMER_NUMBER = '2335') ORDER BY CUSTOMER_NUMBER, LOCATION";
myDist.DataBind();
}
}
protected void ddlDistributor_SelectedIndexChanged(object sender, EventArgs e)
{
if (((DropDownList)FormView1.Row.FindControl("ddlDistributor")).SelectedIndex == 0)
{
return;
}
string storeNbr = ((DropDownList)FormView1.Row.FindControl("ddlDistributor")).Text;
if (storeNbr.Length > 0)
{
sqlSelectedDistributor.SelectParameters["CUSTOMER_NUMBER"].DefaultValue = storeNbr;
DataView dv = (DataView)sqlSelectedDistributor.Select(DataSourceSelectArguments.Empty);
if (dv.Table.Rows.Count == 1)
{
((TextBox)FormView1.Row.FindControl("DistributorTextBox")).Text = Util.BlankForNull(dv.Table.Rows[0].ItemArray[0]);
((Label)FormView1.Row.FindControl("lblAddress")).Text = Util.BlankForNull(dv.Table.Rows[0].ItemArray[1]);
((Label)FormView1.Row.FindControl("lblStoreCSZ")).Text = Util.BlankForNull(dv.Table.Rows[0].ItemArray[2]);
((Label)FormView1.Row.FindControl("lblStorePhone")).Text = Util.BlankForNull(dv.Table.Rows[0].ItemArray[3]);
((Label)FormView1.Row.FindControl("lblStoreFax")).Text = Util.BlankForNull(dv.Table.Rows[0].ItemArray[4]);
}
}
((DropDownList)FormView1.Row.FindControl("ddlRAIssuedBy")).Focus();
}