我的页面加载代码:
if (!IsPostBack)
{
base.PageLoad();
GetReqPndActTknByMe(base.LogShortID);
radSLA.DataBind();
radSLA.SelectedValue = "Yes";
BindDataToDropdownListAction();
ucEmployeeDetails.BindDataToCountryDropdownList();
ucVisaDetails.BindDataToVisaTypeDropdown();
}
我使用以上两种方法将我的下拉值绑定到用户控件。
但是,当点击提交以批准请求时,我的值将设置为默认值:
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
string requestID = txtRequestID.Text;
string reqStatus = txtStatusID.Text;
string actTypeID = ddlAction.SelectedValue;
int reqType = 40001;
BVTBusiness.PendingInviteLetter busAction = new CSCI.Portal.Business.VisaTracking.PendingInviteLetter();
BVTEntity.BusinessVisaRequest entRequest = new CSCI.Portal.Entity.VisaTracking.BusinessVisaRequest();
entRequest.RequestID = requestID;
entRequest.ApproverShortID = base.LogShortID;
entRequest.ActionTypeID = actTypeID;
if (reqStatus == Constant.WF_STATUS_PEN_WITH_HOME_CM)
{
if (actTypeID == "20005" || actTypeID == "20003")
entRequest.ApprovalComments = txtActionComments.Text;
else
entRequest.ApprovalComments = "Service Agreement Applicable : " + radSLA.SelectedValue + " Remarks : " + txtActionComments.Text;
}
if (reqStatus == Constant.WF_STATUS_PEN_WITH_OGM)
{
if (actTypeID == "20005" || actTypeID == "20003")
entRequest.ApprovalComments = txtActionComments.Text;
else
entRequest.ApprovalComments = "Service Agreement Applicable : " + radSLA.SelectedValue + " Remarks : " + txtActionComments.Text;
}
if (reqStatus == Constant.WF_STATUS_PEN_WITH_HOST_CM)
{
if (actTypeID == "20005" || actTypeID == "20003")
entRequest.ApprovalComments = txtActionComments.Text;
else
entRequest.ApprovalComments = "Service Agreement Applicable : " + radSLA.SelectedValue + " Remarks : " + txtActionComments.Text;
}
if (string.IsNullOrEmpty(entRequest.ActionTypeID))
{
//base.ShowErrorMessage(objLookup.GetMessageInformation(2121).MessageText);
}
else
{
BVTEntity.BusinessVisaRequest entRetRequest = busAction.SaveApproverActnTkn(entRequest);
string requestXML = entRetRequest.RequestXML;
pnlAction.Visible = false;
BindGrid(requestXML);
if (actTypeID == "20005")
{
base.ShowMessage("Request Rejected Successfully", Constant.T_INFORMATION);
}
else if (actTypeID == "20004")
{
base.ShowMessage("Request Approved Successfully", Constant.T_INFORMATION);
}
else if (actTypeID == "20003")
{
base.ShowMessage("Request Send back Successfully", Constant.T_INFORMATION);
}
}
}
catch (Exception ex)
{
base.ShowErrorMessage(ex.Message);
}
}
批准后输出:
我的绑定功能:
public void BindDataToCountryDropdownList()
{
BVTBusiness.EmployeeDetails busRequest = new BVTBusiness.EmployeeDetails();
string countries = busRequest.GetCountries();
if (string.IsNullOrEmpty(countries))
{
countries = "<ITEMS><ITEM CODE=\"0\" CDDesc=\"" + Constant.T_FLDDROP_INTIALTEXT + "\"/></ITEMS>";
}
else
{
string firstNode = "<ITEMS><ITEM CODE=\"0\" CDDesc=\"" + Constant.T_FLDDROP_INTIALTEXT + "\"/>";
countries = countries.Replace("<ITEMS>", firstNode);
}
dscountrylist.Data = countries;
ddlTravelFrom.DataBind();
ddlTravelTo.DataBind();
ddlCountry.DataBind();
}
答案 0 :(得分:0)
你绑定了pageload的下拉列表吗?我以前多次遇到过这个问题很多次,我从来都不知道它为何被解决了。请尝试以下方法检查它是否有所作为。
ddlProgrammeYear.EnableViewState = true;
否则,我真的会要求你彻底调试它,看看下载时间是什么时候填充了它的值。 还要检查一下,看看你是否遗漏了什么: http://msdn.microsoft.com/en-us/library/ms178472.aspx
让我知道它是怎么回事。