Web Forms :: GridView Sort Is Working Only First Time

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


Similar Messages:

Forms Data Controls :: GridView Sort Not Working?

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

Forms Data Controls :: Div Collapses Every Time Click On GridView's Sort Column Header?

Feb 8, 2010

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:

<script type="text/javascript" language="javascript">
function toggleDisplay(id) {
var obj = document.getElementById(id);
obj.style.display = (obj.style.display == "none") ? "" : "none";
return false; // cancel the href
}
</script>

[Code]....

View 6 Replies

Forms Data Controls :: Sort Not Working In Gridview After Changing Headings

Nov 1, 2010

I'm developing a bilingual web site, and therefore, I'm changing the text of the headings and the select buttons of my gridviews. I just discovered that if I set some code like below in the rowdatabound event of the gridview, the "linkbuttonish" headings get replaced by unclickable text. Thus, sorting the gridview is suddenly not working. What should I write instead?

If Session("lang") = "en" Then
If e.Row.RowType = DataControlRowType.Header Then
e.Row.Cells("name").Text = "Given name"
End If
End If

I guess that I should write something else than "e.Row.Cells("name").Text" to still have the click-behaviour, but I don't know what. The same question arises for the select linkbutton in a cell of the gridview's datarows.

View 2 Replies

Forms Data Controls :: Gridview Sort Expression - How To Reset A Gridview Or Prevent It From Doing A Sort

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

Forms Data Controls :: Sort Not Working In All Gridviews?

Nov 2, 2010

I'm developing a bilingual web site, and therefore, I'm changing the text of the headings and the select buttons of my gridviews. I just discovered that if I set some code like below in the rowdatabound event of the gridview, the "linkbuttonish" headings get replaced by unclickable text. In another thread, I was told to change

If Session("lang") = "en" Then
If e.Row.RowType = DataControlRowType.Header Then
e.Row.Cells("name").Text = "Given name"[cod]...

in the myGV_DataBound sub.This works well, but not everywhere. A few gridviews are populated from codebehind, and this is where things go wrong. What happens is that - nothing happens (it's still the original heading). I added a Watch, but once the HeaderText property changed, the Watch never yielded another result, but stayed with the new value.

Now I suspect that even though the HeaderText property has changed, this doesn't get reflected in the GV when populated from codebehind.

I guess that I should write something else than "e.Row.Cells("name").Text" to still have the click-behaviour, but I don't know what.

The same question arises for the select linkbutton in a cell of the gridview's datarows.

View 2 Replies

Forms Data Controls :: Listview Dataset Tables[0] DefaultView Sort Not Working?

Jan 15, 2010

I have a Listview control that DataBind programatically... ie I am NOT using SqlDataSource or such... I am attempting to sort a column... clicking on a link button that fires the "Sorting" event. So, after cliking on the column heading... I end up in this routine, where I hardcoded the .Sort = values (just for testing). The code is executed... but the RESULT show via Listview remains the SAME. No change!

How to fix this? I've seen some other posts examples that uses this event (ListView1_Sorting) and then sort via LINQ. I am not ready to try that...

Just want to know why dsPaymentList.Tables[0].DefaultView.Sort does not work?

I followed the example at: [URL]

protected void ListView1_Sorting(object sender, ListViewSortEventArgs e)
{
string sortExpression = e.SortExpression + " " + e.SortDirection;
DataSet dsPaymentList = new DataSet();

[Code]....

View 3 Replies

Forms Data Controls :: Sort Functionality Not Working When Binding The Grid To A Collection Type Object?

Apr 1, 2011

My Grid is bound to a collection type datasource. When I try to sort the Columns in the Grid I get Javascript error saying sorting event not implemented. Why is the default inbuilt sort functionality not working which worked fine when I directly used a sqlDataSource using smart tag. Do I have to write some code to achieve sorting ?

View 1 Replies

Forms Data Controls :: How To Change Sort Column Header Text And Retain The Sort Link

Jun 3, 2010

I have a simple dynamic gridview with following code -

GV = new GridView();

View 3 Replies

Forms Data Controls :: Gridview Sort Manually With Button Outside Of Gridview?

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

Custom Sort In ASPXGridView Not Working With Paging?

Nov 2, 2010

I've implemented a custom sort for a aspxgridview, following the steps mentioned here: [URL]

However, I've noticed that it only sorts the current active page, so whenever I go to another page I have to click again on the column to sort it.

Is this behavior correct, or am I missing something? How can I solve it?

PS: I thought about capturing the PageIndexChanged event and manually sort the active page, but that seems too hackish...

View 3 Replies

DataTable.DefaultView.Sort Doesn't Seem To Be Working?

Feb 19, 2010

I populate a DataTable, then sort the DefaultView of that DataTable. When I set the DataTable as the source for my report, the sort doesn't work. here is the code (GetData returns a valid DataTable):

Dim dt As DataTable = a.GetData(Parm1, Parm2, Parm3)
If rbtSortByField1.Checked Then
dt.DefaultView.Sort = "Field1 ASC"
ElseIf rbtSortByField2.Checked Then
dt.DefaultView.Sort = "Field2 ASC"
ElseIf rbtSortByField3.Checked Then
dt.DefaultView.Sort = "Field3 ASC"
End If
rpt.SetDataSource(dt.DefaultView.Table)
'This also doesn't work
'rpt.SetDataSource(dt)

View 1 Replies

VS 2008 Grid View Sort Column Not Working

Aug 17, 2010

I have a GridView in ASP.Net 3.5. I added BoundFields as columns, set DataField and Header Text. Total I have 6 columns like that. Although I set "AllowSorting=True" in design view, when I run this page, all the columns didn't have hyper link that I can click on it and sort that particular column. I bind this column at code behind by using datatable.
gv.DataSource = dtDispatch
gv.DataBind()

View 1 Replies

Web Forms :: DataView.Sort Vs List.sort?

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

Web Forms :: Sort Datatable Without DefaultView.Sort?

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

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

Forms Data Controls :: How To Sort TemplateField Value In GridView

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

Forms Data Controls :: How To Sort The Columns In Gridview

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

Forms Data Controls :: Gridview Does Not Sort On GvClaimDetails_Sorting?

Oct 1, 2010

[Code]....

Gridview does not sort on gvClaimDetails_Sorting


View 6 Replies

Forms Data Controls :: Don't Get Sort Columns In Gridview

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

Forms Data Controls :: Sort A Date In Gridview?

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

Forms Data Controls :: Sort Even Does Not Get Fired In Gridview?

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

Web Forms :: How To Reset Gridview Sort On Buttonclick Event

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

Forms Data Controls :: Gridview With Checkbox Update One Time In A Button Click Not Every Time?

Mar 11, 2010

I have a gridview on my page. I have a checkbox in each row of this gridview. For each checkbox in the gridview, I'd like to update my table accordingly, but I don't want them to have to hit a submit button every time they check the checkbox. I want them to check all the boxes they need to and at the end, they should hit one submit button.

View 12 Replies

Forms Data Controls :: How To Sort A Gridview By A Calculated Column

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







Copyrights 2005-15 www.BigResource.com, All rights reserved