Web Forms :: How To Reset Gridview Sort
Feb 25, 2012
<asp:GridViewid="gridview"
runat="server" DataSourceID = "SqlDataSource1"
PageSize="30" EmptyDataText = "No Records Found" EmptyDataRowStyle-HorizontalAlign ="Center"
AllowPaging="true"
HorizontalAlign="Center" BorderColor ="Black" Width = "762" Font-Names="Calibri"
[Code] ....
First time on page load
Sorting works fine
But if I done sorting on gridview column then its always the same , How to assign result of SQL query to my result
so that my sort will show result from sql query order not the order of grisview sort ...
View 1 Replies
Similar Messages:
Sep 23, 2010
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 tried this:
Tried setting gridview1.sqldatasourceid = null; gridview1.allowsorting = false; gridview1.databind();
Here I get an error that says that the data source does not support sorting? Doesnt it say gridview1.allowsorting = false;
I also tried gridview1.sort("", SortDirection.Ascending); This does nothin... except query my database one more time because i have a onSorting event that looks like this:
[Code]....
Here is an example of just one of those SLQ statements inside GetSQLQuery:
[Code]....
View 1 Replies
Feb 23, 2012
I have a gridview and I used sqldatasource to bind data with gridview
Sorting is working correctly
But on first button click event If i sort column Name by desc
and on second button click event the sort order for column name id desc only
How to reset column sort as per sql query on every button click event ?
View 1 Replies
Jun 3, 2010
I have a simple dynamic gridview with following code -
GV = new GridView();
View 3 Replies
Jan 18, 2011
I have a gridview with data. I want a button which is not part of the gridview. Then if I press a button the gridview is sorted by two colums. i.e column1 ascending column2 descending.
I am not looking to work with a Sqldatasource as I use a data access layer. So the sort would have to be from a datatable and databind or directly with the gridview.
View 3 Replies
Mar 3, 2011
I have an application where the user scrolls down through a grid and clicks a SELECT button to populate some textboxes based on the content of the grid. On the return from the postback the selected row is out of sight because the grid comes back reset to the top within the scroll window.
Is it possible to have the postback return with the highlighted selected row visible rather than forcing the user to scroll back down to find the selection?
View 2 Replies
Aug 11, 2010
I have a web form with some labels, textboxes, buttons and a gridview. The gridview has AllowPaging ="true". Girdview displays record numbers (hyperlinked), When I click on a record number in the grid view it populates textbox1. Then I hit the 'Search button to auto populate the form the that record data from the database.
My problem is when I am on say 5th page on my grid view and click a record number to go in textbox1, and then click on the search button to auto populate the form, the gridview goes back to page 1.
How do I make the search button not reset/refresh the gridview?
View 6 Replies
Jan 20, 2011
I have webform that is used to search for records and displays them...the form contains a dropdownlist, a textbox, a button, and a gridview...user select an entry from the dropdown, type in a matching value and then click on the button to add the entry into the gridview. All of these seem to be working just fine...however, the issue am having is this...after working with the first entry and users search for the second record, the gridview still maintains the entries from the first search. How do i go about resetting the gridview each time there is a new search? Here is what my code looks like.
[Code]....
[Code]....
[Code]....
How do I get the gridview to reset the next time the btnSearch button is clicked?
View 6 Replies
Mar 7, 2010
Actually i want to ask which is the best for sorting in Asp.Net is it DataView.Sort Method or List<Object>.Sort() method.
View 1 Replies
Apr 20, 2010
I'm looking for a way to sort the rows of a datatable without setting the DefaultView.Sort to a specific column. I have a datatable in session that users can add records to. I want them to be able to sort the data by clicking on a button. But new records added after that need to show up at the bottom of the list until the sort button is clicked again.
View 2 Replies
Sep 12, 2010
Right now I have a gridview with databind. My menu item consist of the 7 days of the week. Everything works fine except for one thing, the page index. Right now by default it loads the results for Monday. If I click on Pg 2 for Monday, and then I click on Tuesday, the page number stays at page 2 and the data remains the same. I have to click on Pg 1 or Pg 3 before the data would refresh and change the result to Tuesday's data.
I've tried adding databind() to the MenuClick event but if Monday has 3 pages, and they click on Tuesday which only has 2 pages, it would give me an error. Also the adding of the Databind() still doesn't fix the page index when I click on a different day.
How do I reset the page index when the user clicks on the day.
[Code]....
View 10 Replies
Mar 26, 2010
I have a DropDownList when selected, brings up Detail Info in GridView1. That GridView has a LinkButton when selected brings up the final Detail Info, in GridView2. need to have the GridView2 clear out and display as when it is "EmptyDataText", when the DropDownList is changed.
View 5 Replies
Feb 16, 2012
My Gridview sort is working only first time. My Gridview sort only first time when I click on any column
I want ASC > DESC
Again DESC > ASC
and Again ASC > DESC this way my sort should work
I have changed my code
I added Gridview binding to PAge_Load function
Code is below
Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myUserInfo As GCS_User_Info = Session("UI")
If Not Page.IsPostBack Then
GRDView.DataSource = GetSortableData(String.Empty) 'System.Drawing.FontFamily.Families
GRDView.DataBind()
[Code] ....
View 1 Replies
Jun 20, 2010
I want to create simple rating page where player's place,name and rating is displayed. I've created database with ID,Name and Rating Columns, binded Gridview to this database and created TemplateField "Place". With following code I've created numbered list for Place:
protected void Page_Load(object sender, EventArgs e){
for (int i = 0; i < GridView1.Rows.Count; i++)
View 4 Replies
Feb 2, 2011
I have 12 columns in a grid i want sort 3 of them when user clicks on Header, how can i do this.
U want these columns to be sort WOnumber,DD,PO.
View 1 Replies
Oct 8, 2010
I'm a newbie to .NET, so the solution might be really trivial. I have a database, I have an Entity Data Model, I add in my Index.aspx page an EntitryDataSource and a GridView. I connect them and everything works fine (the data is displayed as expected). The problem is that clicking on the coulmn name or on the pagination lists doesnt do a thing... Although I did set the properties AllowSorting="True" and AllowPaging="True". I also tried with another datasource type (SqlDataSource) and the same problem.
View 2 Replies
Oct 1, 2010
[Code]....
Gridview does not sort on gvClaimDetails_Sorting
View 6 Replies
Mar 9, 2010
i am having a gridview in which all columns get dynamically added, i applied sorting in it, all column added as boundcolumn get sort properly but two column which are added as templated column do'nt get sort. Though my dataview have these column as it is.
View 2 Replies
Mar 14, 2011
i have the following code . .
[Code]....
i need to sort according to Due_By i mean most recent one shpuld come first . .
View 8 Replies
Mar 24, 2011
I am using gridview created by visual components. I have registered gridview_onsortclick event during the page initialisation, but when i try to click on the header of any column, this event does not get fired at that time. This event gets fired only after all the controls, sorting query is generated, filling the current dataset is done. But the same event is getting fired before query is generated and dataset is filled,for the other page. And one more thing to add with it, I want the sort function to be done on the whole dataset regardless of current page. Why is there such a difference in both the pages?
View 2 Replies
Jan 3, 2011
i want to see the sales in the grid view based on the month selected from drop down list. Ex: when I select June 2010 from the ddl box, the sales for that month are correctly displayed in the grid view. I go to page 4 to look at some sales there and then switch the month to August 2010 to see sales for that month instead. Here is the problem. When I switch the month, it show August 2010 sales, but stays in page 4 instead of going back/resetting back to page 1 of August 2010 sales.
How do I reset the grid view page back to the first page of August 2010 sales?
I am fairly new to ASP. If I have missed an imp. detail in this post, let me know and I will get that info. out there.
View 4 Replies
May 25, 2010
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...
View 4 Replies
Apr 22, 2010
I have the following sorting code that works find when clicking on a column header in a gridview.
Now, I'd like to fire this sorted table & fire it on load instead of having the user have to click a column heading.
how to do that?
Here's my code:
[Code]....
View 3 Replies
Jan 6, 2011
I have a gridview column named "Job Number" and the number is in this format: 01-04-11-3215, 01-04-11-3216 and so on...
Since the first few characters represent the date I need to sort on the last 4 digits.
View 2 Replies
Dec 7, 2010
i want to sort the datagrid(gridview) programatically.
View 4 Replies