I'm trying to implement a GridBoundColumn
for filtering as described in this Telerik demo.
The example queries the database directly using SqlDataAdapter
, but I want to use an existing class elsewhere in my project, and configure the DataSource of the filter RadComboBox
in the RadGrid
to use the LINQ data context common to the rest of my project.
namespace MyProject.DataLib
{
// Data context lives here.
}
namespace MyProject.UI
{
public partial class MyUI : PageBase
{
public class rgcFilterColumn : GridBoundColumn
{
...
protected void list_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
using (MyP开发者_如何学JAVAroject.DataLib = new DataLib(CurrentUser)) // error CurrentUser
{
((RadComboBox)o).DataTextField = DataField;
((RadComboBox)o).DataValueField = DataField;
((RadComboBox)o).DataSource = ???; // LINQ would go here...?
((RadComboBox)o).DataBind();
}
}
}
}
}
The user defined by CurrentUser
has the necessary credentials, however when I try to do this (which I know is wrong):
Cannot access non-static property 'CurrentUser' in static context.
What would be the best way to accomplish what I want here, as well as clarify my incomplete understanding of why I can't simply talk to my existing data context?
Found the solution, should've just looked around more closely.
精彩评论