I am creating a custom webpart for SP 2010. I need to use the SPDataSource control with a dropdownlist. I got this to work perfectly if the SP list is hardcoded in the node, but what if I dont know which list needs to be used and this information is passed by the user via the "Edit Web Part" of the custom web part?
Here's what works:
<SharePoint:SPDataSource runat="server" ID="FolderNameDataSource"
DataSourceMode="List" SelectCommand="<Query><OrderBy><FieldRef Name='Title'
Ascending='true' /></OrderBy></Query>">
<SelectParameters>
<asp:Parameter Name="ListName" DefaultValue="Forms Library" />
</SelectParameters>
</SharePoint:SPDataSource>
<asp:DropDownList runat="server" ID="ddlFolderNames" CssClass="title"
DataSourceID="FolderNameDataSource" DataTextField="Title" DataValueField="Title"
AutoPostBack ="true">
</asp:DropDownList>
DefaultValue is where the SP list is passed. How can I do all of this programmatically? I capture the user entered listname like this:
_listname = this.WebPart.FolderNameValue;
Now how can I pass this to the parameter?
Thanks, Ninel