The problem I have run into using this selector is that I don't want to display my tables by username, which is the default. Some of the tables with which I work do not have a username. To use the selector, the table would have to have a field labeled 'Username'; otherwise, an error would result. Another problem will be listing a selector by comparing values from two tables; which this does not. I will delve into this topic later.
I just found out how he has the selector default to filling the gridview selector with sites based on username. In the code behind the main page, I define the database and the table along with other information about my data to display in the selector:
protected void Page_Load(object sender, EventArgs e)
{
//assign page name to master page
Label pageLabel = (Label)Page.Master.FindControl("ux_PageTitleLabel");
pageLabel.Text = "Main";
//set up the user control
MainSelector.Database = "CostRecovery";
MainSelector.Table = "CRList";
MainSelector.DataKey = "LC";
MainSelector.OrderBy = "CO#";
MainSelector.ResultText = "Sites";
MainSelector.SelectorChanged += MainSelector_SelectorChanged; //register the event from the selector
if (!IsPostBack)
{MainSelector.ShowUserButton = false; // Setting this to true causes the selector to default fill by username
MainSelector.AddResultColumn("SiteDescription", "Site Name");
MainSelector.AddResultColumn("LC", "Ledger Code");
MainSelector.AddResultColumn("CO#", "Contract Number");
MainSelector.AddResultColumn("PjMgr", "Project Manager");
MainSelector.AddResultColumn("CRStatus", "CR Status");
It is the MainSelector.ShowUserButton that sets off the default fill by username. When called and if true, the procedure calls the FillResultsByUserName routine.
public bool ShowUserButton
{
set
{
HttpContext.Current.Session[UniqueName + "ShowUserButton"] = value;
if (value)
{
ux_UserResults.Visible = true;
FillResultsByUserName(); //add the results that belong to the user to the gridview
}
}
get
{
if (HttpContext.Current.Session[UniqueName + "ShowUserButton"] == null)
HttpContext.Current.Session[UniqueName + "ShowUserButton"] = false; //default to false
return (bool)HttpContext.Current.Session[UniqueName + "ShowUserButton"];
}
}
I don't expect anyone without all the code to fully understand what is going on here. I don't completely. But as a reminder to me of what I found today, it will do. I do have a foundation on how this selector works now and will be able to customize it to work with multiple tables hopefully.


