Automatically populating a UserControl

M

Mark

Hi,

I'm new to ASP.Net, but not to c#, so I'm finding some things a little
wierd in this internet based world, especially passing data from page
to page.

I have created a UserControl to search for data. It will first be
displayed on the homepage of my website and then on a search results
page. When the page loads up, I want to be able to repopulate the
options that were first selected on the homepage.

I would like the UserControl to handle this itself, so that if it the
fields were populated on the homepage, then they'll be populated on the
search results page.

I've sucessfully done this for TextBox controls and for DropDownList
controls using the following code.

protected void Page_Load(object sender, EventArgs e)
{
// Populate DropDownList controls
if(Request.Form[SearchRadiusList.UniqueID] != null)
SearchRadiusList.SelectedValue =
Request.Form[SearchRadiusList.UniqueID];
if (Request.Form[FilterTypeList.UniqueID] != null)
FilterTypeList.SelectedValue = Request.Form[FilterTypeList.UniqueID];

// Populate TextBox controls
if (Request.Form[txtFindTitle.UniqueID] != null)
txtFindTitle.Text = Request.Form[txtFindTitle.UniqueID];
if (Request.Form[txtSearchNames.UniqueID] != null)
txtSearchNames.Text = Request.Form[txtSearchNames.UniqueID];
}

However, I have some CheckBox controls that are also on the UserControl
and I can't find anyway to automatically populate those controls. Is
this possible? Any help would be much apprectiated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top