Hey,
I have a C# custom control that I am using to display an address form. On the control, I have a select for picking your state. On the pageload I set defaults for the select. I have a public method exposed where I pass a variable to assign all the address information.
My problem is that the selects do not update to have the correct selected value when I run my method. Any thoughts?
Below is the code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//Epicor Soap Stuff
using Clientele.Application.Client;
using Clientele.Application.Common;
using Clientele.Modules.Party.Common;
using Clientele.Modules.Party.Interface;
using System.Configuration;
using System.Net;
using System.Data;
namespace AccountCenterUserControls.Address
{
public partial class AddressFieldSet : System.Web.UI.UserControl
{
//Credentials
static String EpicorWSLogin = ConfigurationManager.AppSettings["EpicorWSLogin"].ToString();
static String EpicorWSPassword = ConfigurationManager.AppSettings["EpicorWSPassword"].ToString();
static String EpicorWSDomain = ConfigurationManager.AppSettings["EpicorWSDomain"].ToString();
NetworkCredential myCredentials = new NetworkCredential(EpicorWSLogin, EpicorWSPassword, EpicorWSDomain);
private epicor_Organization.OrganizationFullDataSet.PhysicalAddressRow _Address;
protected void Page_Load(object sender, EventArgs e)
{
//Load Address Data
epicor_ValueListEntry.ValueListEntry ValueListEntryWS = new epicor_ValueListEntry.ValueListEntry();
ValueListEntryWS.Credentials = myCredentials;
region.DataSource = ValueListEntryWS.GetByListID(ValueListName.PhysicalAddressRegion).ValueListEntry.Select("", "Description ASC");
region.DataTextField = "Description";
region.DataValueField = "Entry";
region.DataBind();
country.DataSource = ValueListEntryWS.GetByListID(ValueListName.PhysicalAddressCountry).ValueListEntry;
country.DataTextField = "Entry";
country.DataValueField = "ValueListEntryID";
country.DataBind();
//Set some inteligent defaults for the state/country dropdown
country.Value = Clientele.Modules.Party.Interface.Country.USA.ToString();
region.Value = "MD";
}
public void Set(epicor_Organization.OrganizationFullDataSet.PhysicalAddressRow Address)
{
_Address = Address;
address1.Value = Address["Address1"].ToString();
address2.Value = Address["Address2"].ToString();
address3.Value = Address["Address3"].ToString();
city.Value = Address["City"].ToString();
zip.Value = Address["PostalCode"].ToString();
region.Value = Address["Region_"].ToString();
country.Value = Address["CountryID"].ToString();
}
public epicor_Organization.OrganizationFullDataSet.PhysicalAddressRow Get()
{
_Address["Address1"]=address1.Value;
_Address["Address2"]= address2.Value;
_Address["Address3"]=address3.Value ;
_Address["City"] = city.Value;
_Address["PostalCode"] = zip.Value;
_Address["Region"] = region.Value;
_Address["CountryID"] = country.Value;
return _Address;
}
}
}
From the parent controlI call the Set() function in it's Page_Load event. All data except my selects get set correctly.
Is my problem that I cannot set the value of a select after the Page_Load event? How can I get around this?