Solved

Populating the usercontrols with values from list

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

16 Experts available now in Live!

Get 1:1 Help Now