View Full Version : Casting the IList<---> functions into DataTable
ranine
01-21-2007, 09:28 AM
Hi,
How can I cast the function of IList generic collections into DataTable, as I want to generate data from mySQL server and then to set them into a placeholder or any webcontrol????
//search//
public IList<SearchInfo> GetSearch()
{
}
//====> to cast it this way//
public DataTable GetSearch(){
}
I am in need for a help :( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Regards,
Ranine
WesWilson
01-22-2007, 03:01 PM
Ranine, I don't have a direct answer for you, but perhaps another approach would work as well.
Why do you need a dataset? What are some of the UI controls you are feeding?
The GridView, for instance, can be bound to any collection of objects that implements IEnumerable, although you lose the sorting functionality unless you implement it separately (http://www.codeproject.com/useritems/GridViewObjectDataSource.asp).
In fact, you can use a Presenter class to allow looser coupling (and dependency injection via Spring) with a control as complicated as a GridView.
public void PerformSearch()
{
ObjectDataSource docList = new ObjectDataSource();
docList.ID = "ODSDocuments";
docList.TypeName = typeof(DocumentSearchRepository).ToString();
docList.SelectMethod = "GetDocumentsByCompany";
docList.SelectParameters.Add("company", TypeCode.String, view.Company);
docList.Select();
view.ODSDocuments = docList;
view.GrdDocumentsVisible = true;
}
The databinding is implemented in the view.ODSDocuments setter on the code behind page. Let me know if you want more detail on that.
I don't want to lead you down a rabbit trail, but I don't know if you really need to get a datatable to accomplish what you are trying to do.
Best wishes,
Wesley
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.