开发者

Unable to cast object of type 'CompaniesDataTable' to type 'CompaniesDataTable'

Has anyone come acro开发者_开发百科ss an error like the following:

Unable to cast object of type 'CompaniesDataTable' to type 'CompaniesDataTable'.

Here is the code that is causing the error:

    protected void ObjectDataSource_Companies_Selected(object sender, ObjectDataSourceStatusEventArgs e)
    {
        int x = ((Adala.CompaniesDataTable)(e.ReturnValue)).Count;
    }

What I'm trying to do is to get the total number of rows of gridview returned by the objectdatasource but it gives me that error.

Why is it not able to cast type to the same type?


OK Thanks Shaji for not answering, Any way I found a solution for my problem.

I created a BLL Class and instantiated it instead of Direct Instantiating Dataset Classes.

inside BLL i created this method

public Adala.CompaniesDataTable GetCompanies(out int rowsCount)
{
    Adala.CompaniesDataTable dt = Adapter.GetCompanies();
    rowsCount = dt.Count;
    return dt;
}

then i can use the property e.OutputParameters["rowsCount"].ToString(); in the Method Objectdatasource.Selected event

protected void ObjectDataSource_Companies_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
    string rowsCount = e.OutputParameters["rowsCount"].ToString();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜