Grid View

G

Guest

I want to cpunt the number of rows in GridView. But it gives me the
following error
System.InvalidCastException: Unable to cast object of type 'UsersDataTable'
to type 'System.Data.DataView'.

The following is my event handler.

protected void ObjectDataSource1_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{

Label2.Text = "Total Record count in the dropdownlist above= " +
((DataView)e.ReturnValue).Count.ToString();
}
 
T

tomisarobot

generally a good idea to pull apart nested operations when you have
issues like this.

try inspecting what e.ReturnValue actually is. I suspect that its a
UsersDataTable. :)
 
G

Guest

When I do UsersDataTable it gives me following error

The type or namespace name 'UsersDataTable' could not be found (are you
missing a using directive or an assembly reference?)


Label2.Text = "Total Record count in the gridview above= " +
((UsersDataTable)e.ReturnValue).Count.ToString();
 
M

Muhammad Naveed Yaseen

Put a breakpoint somewhere in ObjectDataSource1_Selected and see
e.ReturnValue in debugger's Watch windows, there you can see
completely qualified typename to which it can be casted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top