Reputation: 507
Is there any procedure to pass DataTable as SelectParameter to ObjectDataSource.
I want to implement this as the datasource for the data control(listview) changes every time depending on the selected value in dropdown or Text changed event occurs in a textbox.
and I'm programatically binding the ObjectDataSource to DataControl. like
DataTable dt=new DataTable();
dt=BL.getSelectedValues(ddlFoo.SelectedItem.Value);
ods.SelectParameters.Add("dataTable",dt);
Any alternative suggestion will also be useful.
Upvotes: 0
Views: 3319
Reputation: 94645
You can configure the ObjectDataSource
to your Business
object.
public class TestSource
{
public DataTable GetTestSource()
{
.....
return dataTableObject;
}
}
And markup,
<asp:ObjectDataSource ID="ObjectDataSource1"
runat="server"
SelectMethod="GetTestSource"
TypeName="TestSource">
</asp:ObjectDataSource>
Or populate ObjectDataSource dynamically,
ObjectDataSource ds = new ObjectDataSource();
ds.TypeName = "TestSource";
ds.SelectMethod = "GetTestSource";
GridView1.DataSource = ds;
GridView1.DataBind();
Upvotes: 3