.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

How to revert the column header sorting in DataGridView

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :Windows Application


I want to get the old state (lets say datagridview default state) of grid after sorting is done. How can I achive this.

Please suggest.

Please remember to click 'Mark as Answer' on the post that helped you.

View Complete Post

More Related Resource Links

Stop Sorting Cross Tab Report Header


Dear, I want to stop sorting in cross tab report header. And also want to sort in specific order. How can i do that? Please help me. Its urgent


Modified column missing when sorting


I resently updated few document libraries on my sharepoint site.  What I did I removed "Content approval" from those libraries and now my modified and created columns are missing from the columns of the list (appear to be hidden ).  So, I need to be able to sort by these columns and I have seen many people asking about this same question but I haven't found any answer to this issue.  The columns are still there but I they dont show up in the columns of the library.  I can still create a view with this columns but i cant sort by them.

Is this a bug or is there a reason why sharepoint does this? 


DataGridView>Edit Columns> Column Read Only property is unwilling to change

Hello, I am facing the following mystery: When changing the read only property of a column to false and reopening the "edit columns" window, it mysteriously turns back to true. Even when closing the designer and changing it in the designer code, the resulting execution does not allow edit, as well as when re-opening the designer you see true again.             this.numberDataGridViewTextBoxColumn1.DataPropertyName = "Number";             this.numberDataGridViewTextBoxColumn1.HeaderText = "Number";             this.numberDataGridViewTextBoxColumn1.Name = "numberDataGridViewTextBoxColumn1";             this.numberDataGridViewTextBoxColumn1.ReadOnly = true;//False is required We thought it might be related to data binding. rebinding the grid did not help as well. The is no other place in the code where it changes. Please advice, Thanks

wpf datagridview checkbox column selection not working fine.

Hi Experts,in my c#.net windows based wpf application i added  a datagridview.dynamically i added checkboxcolumn to that datagridview DataGridViewCheckBoxColumn cbCol = new DataGridViewCheckBoxColumn(); GridSource.Columns.Add(cbCol); and another column is string. to this column am hardcoding the values DataTable _datatable = new DataTable(); _datatable.Columns.Add("Name", typeof(string)); _datatable.Rows.Add("CSRs"); _datatable.Rows.Add("Customers"); GridSource.DataSource = _datatable; till here fine am getting two columns (checkbox and Name)when i am trying to check those checkboxes problem comming.am trying to get the count of the checked rows for that i used below code int cbcount = 0; foreach (DataGridViewRow _dgRow in GridSource.Rows) { if ((bool)_dgRow.Cells[0].Value) cbcount++; } cbcount will give the checked count.but the problem raising here if i check 2 rows it giving 1if i check 5 rows it giving 4if i check 1 row it giving me 0means am getting n-1 resultwhere i did wrong??

Most efficient way to check whether a DataGridView contains some specific text at a specific column

Dear All,   I am looking at the most efficient way to check whether a specific column of a DataGridView contains some text. For example I have a list of firs names and I would like to check whether the text "Bob" already exists in that columns. I would like to avoid to loop through each row but what thinking of using something with "Contains".   Anybody has an idea ?   Cheers,   Kalos

How to scroll the DataGrid (horizontally) when user drags a column header far left or right?

We're working with the WPF DataGrid and I have a question about  dragging column headers: The grid lets the user rearrange the columns, by dragging the column header left or right.  So far, so good. But, sometimes we have many columns, and only the first few columns are visible; so there is a horizontal scrollbar.  In such case, if the user drags a column header to the right edge of the DataGrid window, I want the DataGrid to scroll, automatically, one column at a time.  Is there an easy way to do that? (To be clear: yes, the user can already scroll horizontally by interacting with the horizontal scrollbar, but that isn't what I'm asking about.  I'm asking if the "drag a column header left or right" gesture can cause the DataGrid to scroll left or right.) I guess I could handle various low-level events, but it seems like it shouldn't be necessary -- DataGrid has so much functionality built-in, that I'm guessing it already has the ability to scroll when the user drags the column header to the edge.  So, is there either (a) a property that I can set, to tell the DataGrid to scroll when the user drags a column header to the edge of the window;  or (b) a code example showing how to achieve this effect myself?  Thanks!

SSRS 2008 - repeating a non column header column on every page

Hi - I am working on my first SSRS report and I have mostly all of it down except one issue. Per requirements, I need to display a column that is a non header column to repeat on every page while printing and or when I save the generated report in SSRS as a PDF file. I have seen some previous blog from 2007 where RepeatWith property is recommended to be set to the same name of the Tablix in which the column(s) are embeded, tried that but it is not working. Can any one help me on this or guide me how to resolve this? Thanks, Manny

Sorting a DVWP by Column Total

I have a survey list in Sharepoint 2007, which from what I understand means I can't add a calculated column. In this survey list I have some number columns that need to be calculated for display. They are: (1) Number of Weeks, (2) Number of Hours per Week, and (3) Number of Hours for Credit. In Sharepoint Designer, I've created a Data View Web Part which displays those columns and two additional "calculated columns." Scare quotes because the calculation is happening in the XSL of the web part, not an actual calculated column. These columns are (4) Number of Hours (Column1*Column2) and (5) Eligible Hours (Column1*Column2-Column3). I have the data view grouped by @Author (Created By) and a column total row for each group. I even figured out how to get column totals for all four columns though the nodeset is grouped by Author, which breaks out of the box. Great, beautiful. The final step is sorting the entire view by the column total of Column5. In other words, I want my groups of @Authors listed in descending order by their Total Eligible Hours. Is this possible?

Up Down GridView Icon Image for Column Sorting

I'm trying to add an Ascending and Descending sort direction Icon Image next to the header text of my ASP.NET 2.0 Gridview Columns.I've searched and found some examples that seem to do this but have had difficult time recoding them from C# to VB or some just seemed overly complex for what I want to do.Does anyone have a simple VB solution for sort icons?Thanks,Ethan   

How to Change the Color of Link Label which is a Datagridview Column on a Row Selection?

Hi All I have a Link label as one of the column of Datagridview & also my SelectionBackColor set to Blue. Is there any way that i can change the link label color on a particular row selection as now my selectionbackcolor & link label color is matching...I am unable to the contents of that link label column. Should i do this on design level or in code level? Pls Help

How to make a DataGridView Cell/Column not enterable / selecatble

Hi, I am trying to make a Column in a DataGridView non-entaerable (the user should not be able to set focus to the cell neither using the mouse nor the keyboard). I already tried to change the CurrentCell property in the CellStateChanged. But in this event-handler the CurrenCell is the "old" one; setting it to any value doesn't help, because the value is set after calling this procedure. In Delphi there is an event-handler for entering a cell, where you can tell whether the user is allowed to enter a cell. Is there anything comparable in C#? Any other suggestions?

datagridview add data a column at a time

How do I add to a datagridview a column at a time? I see at http://msdn.microsoft.com/en-us/library/5s3ce6k8.aspx that it is possible to do it a row at a time. I was looking for something similar.      

Data template for Icon in Header of listview on sorting

I have 2 datatemplates that show 2 icons for sorting on ascending and on descending.. <DataTemplate x:Uid="HeaderTemplateArrowDown"> <DockPanel> <TextBlock Text="{Binding}"/> <Path x:Name="arrow" StrokeThickness = "1" Fill = "gray" Data = "M 5,10 L 15,10 L 10,5 L 5,10"/> </DockPanel> </DataTemplate> <DataTemplate x:Uid="HeaderTemplateArrowUp"> <DockPanel> <TextBlock Text="{Binding }"/> <Path x:Name="arrow" StrokeThickness = "1" Fill = "gray" Data = "M 5,5 L 10,10 L 15,5 L 5,5"/> </DockPanel> </DataTemplate> So now how do i use these in my theme file . How do i use them at a time all over my project in multiple forms from my theme file. Like how do i include these datatemplates into the GridViewColumnHeader Style.

Is it possible to hide column header in list view webparts?


I can't seem to find a way to hide the column header of a list view web part.  Is it possible?  It appears that OOB the only list that doesn't show the column header in web parts is the Link List.


Paging on a different column than the sorting column



Situation: SQL database, Linq to SQL class a ASP.NET page with a LinqDataSource and a gridview.

The table has a ID field, a date field and a Serialnr field.

In my Grid I like to Page on the datefield but to sort on the serialnr field ( or a selectable other field).

Is that possible? Standard the paging is always done on the sort field and when you select a different sort field the page jumps back to the first page., and paging is then done over that sorted column.



sharepoint column Header multiline


Hello Every one,

I am new to SharePoint.

I am using a Issue Tracking List in Sharepoint, and i have lenghthier column header and a small column data.  Is there any simple way of making the column header multiline.

Please let me know hyour suggestions


How to Use Same Header Name for Multiple Column in GridView ?



Hi All ,

         This is my  Needed view ,


                           Report1                 |                          Report2                         | - Main Header


SEL1    |  SEL2    | SEL3   |     SEL4   |       SEL1    |  SEL2    | SEL3   |     SEL4   |   - Sub Header



But afte

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend