C# 页面加载后设置HtmlSelect时出现问题
我有一个C自定义控件,用于显示地址表单。在控件上,我有一个选择来选择您的状态。在pageload上,我为select设置了默认值。我有一个公开的公共方法,在这里我传递一个变量来分配所有的地址信息 我的问题是,当我运行我的方法时,选择不会更新为具有正确的选择值。有什么想法吗 下面是隐藏的代码:C# 页面加载后设置HtmlSelect时出现问题,c#,controls,C#,Controls,我有一个C自定义控件,用于显示地址表单。在控件上,我有一个选择来选择您的状态。在pageload上,我为select设置了默认值。我有一个公开的公共方法,在这里我传递一个变量来分配所有的地址信息 我的问题是,当我运行我的方法时,选择不会更新为具有正确的选择值。有什么想法吗 下面是隐藏的代码: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.U
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;
}
}
}
从父控件,我在其Page_Load事件中调用Set函数。除“我的选择”之外的所有数据都设置正确
我的问题是无法在页面加载事件后设置select的值吗?我怎样才能避开这个问题呢?我已经弄明白了。Page_Load事件在我的Set方法之后触发。我将Page_Load事件替换为Page_Init,一切都很好。我已经解决了这个问题。Page_Load事件在我的Set方法之后触发。我将Page_Load事件替换为Page_Init,一切都很好