| | |
DataGrid SortCommand does not fire
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
I have a DataGrid that I create dynamically in codebehind. I add events to the datagrid, it works fine except of the SortCommand event. It will not fire.
If I change my page_load to create and bind the datagrid everytime when a postback it works. But I don“t want to do an extra databind at a postback.
All other events is working fine so why not the SortCommand???
.net 1.1
Visual studio 2003
Thanx for any help and ideas!
If I change my page_load to create and bind the datagrid everytime when a postback it works. But I don“t want to do an extra databind at a postback.
All other events is working fine so why not the SortCommand???
.net 1.1
Visual studio 2003
Thanx for any help and ideas!
C# Syntax (Toggle Plain Text)
private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { createDataGrid(); bindDataGrid(); } else { createDataGrid(); } } private void createDataGrid() { //Set datagrid properties myDataGrid.ID = "myDataGrid"; myDataGrid.AutoGenerateColumns = false; myDataGrid.AllowPaging = true; myDataGrid.PageSize = 20; myDataGrid.ShowHeader = true; myDataGrid.ShowFooter = true; myDataGrid.AllowSorting = true; //Create datagrid events myDataGrid.ItemCommand += new DataGridCommandEventHandler(myDataGrid_ItemCommand); myDataGrid.PageIndexChanged += new DataGridPageChangedEventHandler(myDataGrid_PageIndexChanged); myDataGrid.ItemDataBound += new DataGridItemEventHandler(myDataGrid_ItemDataBound); myDataGrid.SortCommand +=new DataGridSortCommandEventHandler(myDataGrid_SortCommand); //Create and add bound/template columns to myDataGrid ... } private void bindDataGrid() { //Get data from databse and bind datagrid DataSet ds = new DataSet(); ds = getDataFromDatabase(); dgRuleTables.DataSource=ds.Tables[0]; dgRuleTables.DataBind(); } private void myDataGrid_SortCommand(object source, DataGridSortCommandEventArgs e) { //Conde inside here will never be executed //SortExpression //Rebind datagrid with new sortexpression ! }
0
#2 Oct 22nd, 2009
Did your paging works without rebinding the data?
MARK AS SOLVED if its help you.
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
0
#3 Oct 22nd, 2009
I found the solution. Instead of create datagrid with events in page_load I changed this to page_init.
More info:
http://forums.asp.net/t/947498.aspx
http://www.velocityreviews.com/forum...-solution.html
More info:
http://forums.asp.net/t/947498.aspx
http://www.velocityreviews.com/forum...-solution.html
![]() |
Similar Threads
- Help with datagrid (VB.NET)
- how to populate Datagrid after a click search (C#)
- Viewing Data in Datagrid (VB.NET)
- Dynamic Buttons in Datagrid Not Firing (ASP.NET)
- datagrid cell edit event (C#)
- Datagrid - no value at index ### error when scroll and sort (VB.NET)
- keydown event ina datagrid (VB.NET)
- Remove link frame around picture in Datagrid (ASP.NET)
- Linking to E-mail through datagrid (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Urgent Help!!!!
- Next Thread: same random number for different users
| Thread Tools | Search this Thread |
.net 3.5 access activedirectory advice algorithm application array asp asp.net broadcast c# c++ combobox cs4 custom database datagrid datastructure datetime dbconnection default deploy deployment developer development dialog directrobot drawing e-commerce enabled error excel expression file filter firefox flash form formatting freelance gdi+ httpwebrequest index java javaee javascript keypress linq linux list login mailmerge mono mysql novell operator packaging photoshop php platform pointer post programmer programming region remote remoting reporting resource richtextbox save saving serialization server smoobjects softwaredevelopment sp1 sql sql-server sqlserver statistics stream stringformatting study survey table text-file textbox treeview unix vb vb.net view virtualization visual webbrowser windows winforms wpf






