467,122 Members | 1,288 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,122 developers. It's quick & easy.

Grid View


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();
}
Sep 4 '07 #1
  • viewed: 2128
Share:
3 Replies
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. :)

Sep 4 '07 #2
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();


"to*********@gmail.com" wrote:
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. :)

Sep 4 '07 #3
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.

Sep 5 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by pmud | last post: by
12 posts views Thread by pmud | last post: by
2 posts views Thread by Jan Mueller | last post: by
2 posts views Thread by Rhonda | last post: by
4 posts views Thread by Filippo Pandiani | last post: by
1 post views Thread by Ed | last post: by
2 posts views Thread by probashi | last post: by
2 posts views Thread by Umeshnath | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.