Solved

Populating the usercontrols with values from list

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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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