Hello,
How can I bind the controls to different CSLA Datasources based on different events at run time.For Example.I have say 5 buttons and DataGrid .How can I bind 5 different datasources to the same grid based on the click event of each button?Is it possible to do so?
Thanks
V
Sorry about that Rocky,
Its a web application.C# based.
So you want to click a button and show data set A, then click a different button to see data set B?
Remember that it is your code that returns the data to the CslaDataSource in the SelectObject event handler. So when the user clicks on a button, you could simply load a form-level field with the data to be displayed and then call DataBind() on the grid control to force it to refresh.
The SelectObject event will be raised due to your DataBind() call on the grid control. In your event handler, you can just return the data that was already loaded by the button click event handler:
e.BusinessObject = _dataToDisplay;
Thanks a Lot Rocky, but I could not get it to work completely.
The DataSource does get bound to the Datagrid on the click event of the button but for some reason I have to click the button twice.On the first click only one row is displayed in the grid and on the second click all the rows get displayed.Something to do with refreshing the grid datasource???
I am attaching the code here...
protected
void dsWorkOrderList_SelectObject(object sender, Csla.Web.SelectObjectArgs e){ e.BusinessObject = .
WorkOrderList.Get(Convert.ToInt32(Session["fid"])); } protected void dsWorkOrderSearchList_SelectObject(object sender, Csla.Web.SelectObjectArgs e){ e.BusinessObject =
WorkOrderListOnMyShops.Get(Convert.ToInt32(Session["fid"])); } protected void btnMyShop_Click(object sender, EventArgs e){
WebGrid1.DataMember =
"Default";WebGrid1.DataSourceID =
"dsWorkOrderSearchList";WebGrid1.DataBind();
}
protected void btnMyWO_Click(object sender, EventArgs e){
WebGrid1.DataMember =
"Default";WebGrid1.DataSourceID =
"dsWorkOrderList";WebGrid1.DataBind();
}
By default the grid contains some rows when the page is loaded first.
Im new to ASP.Net and CSLA kindly ignore my coding standards but please do let me know if there are better ways of implementing the same.
Thanks In Advance
V
Copyright (c) Marimer LLC