Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Sorting a grid


Message #1 by Elissa Setarehshenas <elissasetareh@y...> on Thu, 29 Nov 2001 10:37:20 -0800 (PST)
Hi,

I have a datagrid where I specify

 OnItemCommand="GridCmdHandler"

 AllowSorting="True" OnSortCommand="SortGrid" 



I also have a button column on the grid 

 ButtonType="PushButton"

 The problem is then when I click on a field to be

sorted the program dies because of 

System.InvalidCastException: Exception of type

System.InvalidCastException was thrown.



It appears that even though I specify a OnSortCommand

function the program goes to the  OnItemCommand

function where it gets caught up in this line of code

 

Button b = (Button) e.CommandSource;

(apparently the sort column headers are link buttons).



My questions are

1) why is the grid not going to the OnSortCommand

2) How do I get the button type from

DataGridCommandEventArgs at least this way I can

program around it.  I can't change my button column to

link buttons because netscape won't support it.



Tanks for your help

Elissa Setareh



P.S. I know the problem is not in the sort function

because it worked fine when the button column was a

link buttons.  





__________________________________________________

Do You Yahoo!?

Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

http://geocities.yahoo.com/ps/info1


  Return to Index