?
Solved

Populating the usercontrols with values from list

Posted on 2007-03-26
1
Medium Priority
?
285 Views
Last Modified: 2013-11-07
Hello Experts,

I have this function which Returns a list of values as shown below:
 public static List<ReportFilters> GetAllFilters(ReportBuilder Report)
        {
            return ReportBuilderDAL.ListAllFilters(Report.ReportID);
        }

The above one will return List of filters as shown Below:

ColumnName       Condition            FilterValue1           FilterValue2
LastName             Equals                 Smith                      Null
DOB                      Between              1/1/1972                1/1/2000
City                       Not In                  London                  Null

In my ASPX Page I have a user control which Contains 2 dropdown Boxes and two textboxes.

The firstdropdown lists all the ColumnNames
The second Dropdown Lists all the Conditons and textboxes will hold some values.

I am using five instances of the above mentioned usercontrol. My question is, how do I populate the above values in the usercontrol.
For eg.
The selectedvalue in first dropdown should be LastName, Condition should be equals and the first textbox shoudl show smith.

How do I do this Please help

 


0
Comment
Question by:rowmark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
mzalewski earned 2000 total points
ID: 18796297
I think the easiest way would be to expose a 'ReportFilter' property on the user control.
private ReportFilter _selectedFilter = null;

public ReportFilter SelectedFilter {
get { return _selectedFilter; }
set { _selectedFilter = value; }
}

Then bind the data during OnLoad:
if (_selectedFilter != null) {
dropdown1.SelectedValue = _selectedFilter.ColumnName;
dropdown2.SelectedValue = _selectedFilter.Condition;
textbox1.Text = _selectedFilter.FilterValue1
}

Or maybe set up a BindingDataSource. This should be easy with Visual Studio's wizard - Just make sure you change the public property to update the binding source instead of the private variable.

You might also have to expose a couple of public List<string> properties that contains the *possible* values for the dropdownlists.

You could also include the usercontrol in a repeater if you wanted.
0

Featured Post

Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question