Solved

Populating the usercontrols with values from list

Posted on 2007-03-26
1
284 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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

630 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