Monday, March 12, 2012

how to convert objectdatasource to dataView?

hi there...does anyone run into a problem where the objectdatasource cannot be casting into dataview? it aleays works for me except for this time

.csDataView dv = (DataView)objSubCategoriesByUserPermissions.Select();.aspx<asp:ObjectDataSource ID="objSubCategoriesByUserPermissions" runat="server" SelectMethod="GetCategoryByUserPermissions" TypeName="MB.TheBeerHouse.BLL.Articles.Category"> <SelectParameters> <asp:QueryStringParameter Name="articleID" QueryStringField="ID" DefaultValue="-1" /> <asp:ProfileParameter Name="username" PropertyName="username" /> </SelectParameters> </asp:ObjectDataSource> <br /> <asp:SqlDataSource ID="sdcAllCategories" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString%>" SelectCommand="SELECT CategoryID, Title FROM tbh_Categories WHERE (visible = 1) AND (ParentID IS NULL)"> </asp:SqlDataSource>

Unable to cast object of type 'System.Object[]' to type 'System.Data.DataView'.

Hi

ObjectDataSource.select() must return one of the types listed below:

IEnumerable

TheIEnumerable is returned by theSelect method.

DataTable

ADataView is created by using theDataTable and returned by theSelect method.

DataView

TheDataView is returned by theSelect method.

DataSet

The firstDataTable of theDataSet is extracted and aDataView is created and returned by theSelect method.

Object

The object is wrapped in a one-elementIEnumerable collection and returned by theSelect method.

Here is a similar thread that may give you clue:http://forums.asp.net/thread/1491464.aspx

For details about ObjectDataSource.select() seehttp://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.select.aspx

Hope this helps.


thank it does.

Labels: , , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home