Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a webform that returns filled out if there is an existing entry made in a search page. The issue I'm having is in the Page Load section of aspx.cs file. Code below:

C#
protected void Page_Load(object sender, EventArgs e)
        {
            Master.PageTitle = "Account Tracker";
            //Clears Info Messages
            uxInfoMsg.DisplayMessage("", InfoMessage.InfoMessageType.Warning);
            //uxModalInfoMsg.DisplayMessage("", InfoMessage.InfoMessageType.Warning);
            if (!IsPostBack)
            {// Get ID from URL
                int urlTransferReqestID = -1;
                if (Request.QueryString["EntryID"] != null)
                {
                    urlTransferReqestID = DataConverter.StringToInteger(HttpUtility.UrlDecode(Request.QueryString["EntryID"]));
                    FillForm(urlTransferReqestID);

                }
                FillControls();
            }
        }


The issue that I'm having is that the FillControls Method is overwriting previously selected items with the default Fill Control value. For example is there is an entry where the user indicated the value for dropdown1 = John Doe. The FillControls() is resetting the form and more specifically the control to read "--Please Select A Person--"

If there is an existing Entry ID I want the user to have the ability to update the DropDownList to someone else but I also want the control to default to the previously entered value.

I'll do my best to answer any questions you may have.
Posted
Comments
Homero Rivera 27-Jul-15 21:03pm    
Dropdowns have am append property i believe. You should playa around with that maybe.

1 solution

We need to move FillControls() method to appropriate postion inside the IsPostback check.
Try this-
C#
protected void Page_Load(object sender, EventArgs e)
        {
            Master.PageTitle = "Account Tracker";
            //Clears Info Messages
            uxInfoMsg.DisplayMessage("", InfoMessage.InfoMessageType.Warning);
            //uxModalInfoMsg.DisplayMessage("", InfoMessage.InfoMessageType.Warning);
            if (!IsPostBack)
            {// Get ID from URL
                int urlTransferReqestID = -1;
                FillControls();
                if (Request.QueryString["EntryID"] != null)
                {
                    urlTransferReqestID = DataConverter.StringToInteger(HttpUtility.UrlDecode(Request.QueryString["EntryID"]));
                    FillForm(urlTransferReqestID);

                }
            }
        }


Hope, it helps. In case, it doesn't solve your problem, please let me know :)
 
Share this answer
 
v2
Comments
Member 11820531 28-Jul-15 9:41am    
Thanks for the feedback! I've tried the above approach but am still receiving the same output. However, when I debugged the page, I didn't see an instance where the code jumped to the FillControls() method. At this point, I think I may have to look for another solution or different route. Thanks again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900