Solved

Populating the usercontrols with values from list

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now