473,785 Members | 2,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView Sorting Issue

Hey there,

I'm having a problem getting sorting to work.

Here's what the GridView looks like:

"server" ID="updt1" Mode="Condition al">
"false"
AllowSorting="t rue"

AlternatingRowS tyle-CssClass="altro w2"
AutoGenerateCol umns="false"
BorderColor="si lver"
BorderStyle="So lid"
BorderWidth="1p x"
CaptionAlign="L eft"
EmptyDataText=" No data available."

EmptyDataRowSty le-CssClass="altro w2"
GridLines="Hori zontal"
HeaderStyle-CssClass="heade rx"
HeaderStyle-Font-Bold="false"
Id="gridView"

OnSorting="gv_O nSorting"
OnRowCreated="g v_RowCreated"
OnRowDataBound= "gv_RowDataboun d"
RowStyle-CssClass="row2"

Runat="server"
ShowFooter="fal se"
Width="100%" >

"fullname"
HeaderStyle-CssClass="hpad"

HeaderStyle-HorizontalAlign ="Left"
HeaderText="&nb sp;Name"
ItemStyle-CssClass="hyper "

ItemStyle-Width="180"
SortExpression= "fullname"
/>
"hpad"
HeaderText="Bra nch"
HtmlEncode="fal se"
ItemStyle-Width="200"
SortExpression= "officename "
/>
"name_count y"
HeaderStyle-CssClass="hpad"
HeaderText="Cou nty"
HtmlEncode="fal se"
ItemStyle-CssClass="vline "

ItemStyle-HorizontalAlign ="center"
ItemStyle-Width="90"

SortExpression= "name_count y" />
"active"
DataFormatStrin g="{0:N0}"
HeaderStyle-CssClass="hpad"
HeaderText="Tot al"
HtmlEncode="fal se"

ItemStyle-HorizontalAlign ="center"
ItemStyle-Width="50"
SortExpression= "active" />
"activeresa le"
DataFormatStrin g="{0:N0}"
HeaderStyle-CssClass="hpad"
HeaderText="Res ale"
HtmlEncode="fal se"
ItemStyle-Width="50"

ItemStyle-HorizontalAlign ="center"

SortExpression= "activeresl ae" />
"activerefi "
DataFormatStrin g="{0:N0}"
HeaderStyle-CssClass="hpad"
HeaderText="Ref i"
HtmlEncode="fal se"
ItemStyle-Width="50"

ItemStyle-HorizontalAlign ="center"
SortExpression= "activerefi "
/>
"resalepct"
DataFormatStrin g="{0:P1}"
HeaderStyle-CssClass="hpad"

HeaderText="Res ale<br/>Mix"

HtmlEncode="fal se"
ItemStyle-CssClass="vline "

ItemStyle-HorizontalAlign ="right"
ItemStyle-Width="55"
SortExpression= "resalepct"
/>
"escrpo"
DataFormatStrin g="{0:C2}"
HeaderStyle-CssClass="hpad"

HeaderText="per <br/>Order"
HtmlEncode="fal se"
ItemStyle-CssClass="vline "

ItemStyle-HorizontalAlign ="right"
ItemStyle-Width="75"
SortExpression= "escrpo" />
"opentm"
DataFormatStrin g="{0:N0}"
HeaderStyle-CssClass="hpad"
HeaderText="New "
HtmlEncode="fal se"

ItemStyle-HorizontalAlign ="center"
ItemStyle-Width="50"
SortExpression= "opentm" />
"closedtm"
DataFormatStrin g="{0:N0}"
HeaderStyle-CssClass="hpad"

HeaderText="Clo sed"
HtmlEncode="fal se"

ItemStyle-HorizontalAlign ="center"
ItemStyle-Width="50"
SortExpression= "closedtm"
/>
"hpad"
HeaderText="Pro j."
HtmlEncode="fal se"
ItemStyle-CssClass="vline "

ItemStyle-HorizontalAlign ="center"
ItemStyle-Width="50"

SortExpression= "projectedt m" />
"escrowrank "
DataFormatStrin g="{0:N0}"
HeaderStyle-CssClass="hpad"
HeaderText="Clo sed<br/>Esc."
HtmlEncode="fal se"

ItemStyle-HorizontalAlign ="center"
ItemStyle-Width="50"
SortExpression= "escrowrank "
/>
"revenueran k"
DataFormatStrin g="{0:N0}"

FooterStyle-HorizontalAlign ="center"
HeaderStyle-CssClass="hpad"
HtmlEncode="fal se"

HeaderText="Clo sed<br/>Rev."

ItemStyle-HorizontalAlign ="center"
ItemStyle-Width="50"

SortExpression= "revenueran k" />


"gridView" EventName="Sort ing" />


protected void load_gv(string _sproc, string _param)
{
using (FADataBase faDb = DBHelper.GetDat abase(FAUser))
{
string errorString;
try
{
DataTable dt = faDb.oneparamDt (_sproc, _param, out
errorString);
DataView dv = new DataView(dt);
gridView.DataSo urce = dv;
gridView.DataBi nd();
}
catch (dbExecExceptio n sex)
{
errorMessage(se x.ToString());
}
}
}

public void gv_OnSorting(ob ject sender, GridViewSortEve ntArgs e)
{
GridView tempG = (GridView)sende r;
string asdf = tempG.ID.ToStri ng();

if ((string)ViewSt ate["sort"] == "desc" &&
(string)ViewSta te["lastSort"] == e.SortExpressio n)
{
ViewState["sort"] = "asc";
e.SortDirection = SortDirection.A scending;
}
else
{
ViewState["sort"] = "desc";
e.SortDirection = SortDirection.D escending;
}

ViewState["lastSort"] = e.SortExpressio n;
}

The load_gv() basically gets a stored procedure name and then gets a
DataView and binds it to the GridView. My custom OnSorting method
doesn't work. Nothing sorts at all. However, even when I turn off
custom sorting and revert back to the standard sort, nothing sorts
there either. Is it something to do with the DataView? Usually I use a
SQLDataSource. Does anyone know what the issue is? Thanks.

Nov 8 '06 #1
0 1768

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2736
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update not the whole page, but a portion of the page. Strangely enough the URL below http://beta.asp.net/QUICKSTARTV20/aspnet/doc/ctrlref/data/gridview.aspx (VB GridView Paging and Sorting Callbacks example)
1
2904
by: Ram | last post by:
Hi All, I am using Object Data Source to bind data in the gridview. I have set the property AllowSorting=true. While running the application, I could sort the data only in ascending order. Is there any way to achieve two way sorting in gridview ie. both ascending and descending on successive clicks ?. Please give me a suggestion to solve this issue. Thanks in advance.
6
2326
by: GaryDean | last post by:
I liked the DataGrid because I was familiar in walking through it to do custom filling and retrieval of data in cases where standard binding wouldn't do the job. I read somewhere that the object model is the same for the datagrid and the gridview. But as I begin to try to manually load a gridview I notice that there is no such thing as a GridViewItem as there was a DataGridItem. So, it's not the same. Are there any articles or...
4
8252
by: samb | last post by:
When I use manual databinding to a GridView control, as bellow. 'Retrive a DataSet from database Dim ds As DataSet = uda.GetUsers(conectionString) 'gvUsers - The GridView gvUsers.DataSource = ds gvUsers.DataBind()
4
5481
by: kurt sune | last post by:
I have a an aspx page with a gridview. The gridview is data bound to a generic list of custom classes. The gridview's DataSource is thus not set. Now I want to add sorting to it. So I create an eventhandler thus: Protected Sub grdResult_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles grdResult.Sorting
1
2658
by: bpd | last post by:
I am using SQLDataSource with a Gridview. I have sorting enabled on all (3) columns. When clicking on the column's sort hyperlink, nothing happens the first time. Clicking a second time will sort the grid in descending order. Sorting seems OK after that until I exit and come back in to the page. Is this a known issue with the Gridview or is there something obvious I am overlooking. thanks
2
5583
by: sivagururaja | last post by:
Hi All, How can i sorting the Gridview Columns via the code behind. When i tried to sorting the column it doesn't work. SqlConnection con = new SqlConnection("Connection string"); con.Open(); SqlCommand cmd = new SqlCommand(str, con); SqlDataAdapter da = new SqlDataAdapter(cmd);
4
11163
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have a vb.net 2.0 app that is loading a GridView with a DataSource that is returned from a function. The definitions in the function are: Dim ReportDS As DataSet = New DataSet Dim ReportTable As System.Data.DataTable = New System.Data.DataTable("SendTo") The ReportTable is populated row by row by data gotten back from the
0
972
by: =?Utf-8?B?QVZM?= | last post by:
Hi I want to implment cusotm sorting in gridview... Ive a dropdown box on my page where ive all the fields(columsn) to be sorted.. whenever hte user selects the value in the dropdown , the gridview should be sorted... As of now, whenever user selects a value in the dropdown , Im rebinding the grid with sorting applied.... but this is hittng the page performance...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.