Is there any simplified Data Source Control that would allow binding to a local (code behind) page method? Any way to accomplish this with an ODS?
The ODS requires the TypeName parameter which I can’t figure out to to point to the local page (code behind) in a Web Site Project.
<asp:DropDownList ID="DropDownListMain" runat="server" DataTextField="Text" DataValueField="Value"
DataSourceID="DataSourceMain" />
<asp:ObjectDataSource ID="DataSourceMain" runat="server" SelectMethod="GetMyRecords" />
protected IEnumerable<MyRecord> GetMyRecords()
{
yield return new MyRecord("Red", "1");
yield return new MyRecord("Blue", "2");
yield return new MyRecord("Green", "3");
yield return new MyRecord("Black", "4");
}
protected class MyRecord
{
public MyRecord(string text, string value)
{
this.Text = text;
this.Value = value;
}
public string Text { get; set; }
public string Value { get; set; }
}
Not fully tested but this does work. I need to test with UserControls and MasterPages. So, yes, it can be done:
Markup on the page:
Code on the page: