I have a page with a TextBox, a Button, a GridView, and a SqlDataSource. I click the Button to execute the SQL in the TextBox using the SqlDataSource. The SqlDataSource populates the GridView. Everything works as expected until I click a column heading to sort.
When I click a column heading, the GridView disappears and I have to click the Button to display the grid again. When I do, the grid is displayed in the order of the column I clicked.
I don't understand why the GridView is disappearing when I click a column header.
Does anyone know how to fix this so the GridView is sorted and displayed only by clicking the column header?
I have several grid views indide div's, and when I click the Sort header on an open div the div collapses and no sort happens. I believe it is just reloading the entire page but when I surround PageLoad with !ISPostBack then the page redraws as blank. Since the sort script is generated by the GV, I don't know how to stop it from creating side effects.
Here's my code:
I have a gridview which I am trying to be able to sort by clicking the column header. Currently, I have the column header underlined by turning the 'allow sorting' function to TRUE, but when I click the column header, it does nothing.
Is this a good method for displaying a soricon? or are there better ways of doing it;
Also when the gridview is first loaded its sorted by a "Date Submitted" field which is sorted on the data source (stored procedure) is there any way of showing the icon then so people know that it is sorted by "Date Submitted" at the moment the icon only shows when someone re-sorts the grid.
Just spent about 8 hours googling and looking through this forum for a solution on how to make sure that I can dynamically sort. Here is the situation.
I have 1 Gridview that displays 10 different scenarios based on what button is clicked.
I am also returning only top 10 records. I am doing all of the data binding pragmatically. So I have BoundFields, HyperLinkFields etc.
I also want to sort some records. When I change DataSource SQL statement the gridview somehow remembers what the last sort value was and it errors out saying that value "x" cannot be sorted because it does not exists.
I have a merged column of firstname and lastname by "Select firstname + lastname from table" but when it appears in the gridview the header text of the column is "Expr1000". How can I change the header text of that merged column?, and I want to change its text into "NAME".
Is there a way to Sort a Gridview by a Calculated Column? I have a gridview with template fields using lablels and a linq datasource. Those columns sort just fine. I can not get the Calculated column to sort, because there is no sort expression to use...
i have a gridview that has the ability to sort by each of the columns, but suppose if i'm on page 2 of the results and sort any of the columns, it jumps back to page 1. is there a way to keep it on page 2, still have the sorted date work?
I have been struggling with this problem for a long time. Does anyone have any clue about this problem? I created a gridview and set the allowsorting to true. This gridview has four columns: Name, Position, StartDate, and EndDate. I want the gridview to be sorted on the EndDate.
Inside of the save event, I called the BindGrid() function to rebind the datasource to the gridview. The changes will shown immediately, but the problem is that the records are not sorting on EndDate. I have to refresh the page manually to get the view sorted.
I have a grid view with manual sorting. In some cells, the data are numeric and datetime. But due to some constrains, the data type on tables are varchar. The problem here is when I sorting those numeric data, it is treated as varchar.Eg: 1, 12, 13, 2, 23, 3, ...But I wanted the order to be: 1, 2, 3, 12, 13, 23, ...I have tried these method, but it doesnt works.
I have a gridview that is being databound by an SQLdatasource and on RowDataBound i am doing a calculation and then setting
e.Row.cells(17).text = Result
However, when I go to sort it on the website it sorts it based off the previous values.Cell(17) from the datasource reads in all 1's. The numbers I change it to range from 0 to 15. So when I click sort nothing changes because it sees it as all 1's.How can i make the gridivew sort off the changed text values?