| | |
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 |
Tag cloud for .net, c#, datagrid
.net 3.5 7 access advice application appportability array asp asp.net c# calendar chat check combobox connect consultant control database datagrid datetime default deployment development dialog directrobot drawing enabled eventhandlers excel file files firefox flash foreach form formbox freelance gdi+ http httpwebrequest index java javascript linux list listbox login mailmerge maps marshalbyrefobject math messagebox mono mysql notepad odp.net operator oracle packaging photoshop php picturebox pointer post programming remote remoting resource richtextbox save saving silverlight softwaredevelopment sql sql-server string stringformatting suse table tcpclientchannel text-file textbox treeview validation vb vb.net video view virtualization vista visualbasic webbrowser webdevelopemnt win7 windows winforms wordautomation working wpf






