473,238 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

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="Conditional">
"false"
AllowSorting="true"

AlternatingRowStyle-CssClass="altrow2"
AutoGenerateColumns="false"
BorderColor="silver"
BorderStyle="Solid"
BorderWidth="1px"
CaptionAlign="Left"
EmptyDataText="No data available."

EmptyDataRowStyle-CssClass="altrow2"
GridLines="Horizontal"
HeaderStyle-CssClass="headerx"
HeaderStyle-Font-Bold="false"
Id="gridView"

OnSorting="gv_OnSorting"
OnRowCreated="gv_RowCreated"
OnRowDataBound="gv_RowDatabound"
RowStyle-CssClass="row2"

Runat="server"
ShowFooter="false"
Width="100%" >

"fullname"
HeaderStyle-CssClass="hpad"

HeaderStyle-HorizontalAlign="Left"
HeaderText=" Name"
ItemStyle-CssClass="hyper"

ItemStyle-Width="180"
SortExpression="fullname"
/>
"hpad"
HeaderText="Branch"
HtmlEncode="false"
ItemStyle-Width="200"
SortExpression="officename"
/>
"name_county"
HeaderStyle-CssClass="hpad"
HeaderText="County"
HtmlEncode="false"
ItemStyle-CssClass="vline"

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

SortExpression="name_county" />
"active"
DataFormatString="{0:N0}"
HeaderStyle-CssClass="hpad"
HeaderText="Total"
HtmlEncode="false"

ItemStyle-HorizontalAlign="center"
ItemStyle-Width="50"
SortExpression="active" />
"activeresale"
DataFormatString="{0:N0}"
HeaderStyle-CssClass="hpad"
HeaderText="Resale"
HtmlEncode="false"
ItemStyle-Width="50"

ItemStyle-HorizontalAlign="center"

SortExpression="activereslae" />
"activerefi"
DataFormatString="{0:N0}"
HeaderStyle-CssClass="hpad"
HeaderText="Refi"
HtmlEncode="false"
ItemStyle-Width="50"

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

HeaderText="Resale<br/>Mix"

HtmlEncode="false"
ItemStyle-CssClass="vline"

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

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

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

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

HeaderText="Closed"
HtmlEncode="false"

ItemStyle-HorizontalAlign="center"
ItemStyle-Width="50"
SortExpression="closedtm"
/>
"hpad"
HeaderText="Proj."
HtmlEncode="false"
ItemStyle-CssClass="vline"

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

SortExpression="projectedtm" />
"escrowrank"
DataFormatString="{0:N0}"
HeaderStyle-CssClass="hpad"
HeaderText="Closed<br/>Esc."
HtmlEncode="false"

ItemStyle-HorizontalAlign="center"
ItemStyle-Width="50"
SortExpression="escrowrank"
/>
"revenuerank"
DataFormatString="{0:N0}"

FooterStyle-HorizontalAlign="center"
HeaderStyle-CssClass="hpad"
HtmlEncode="false"

HeaderText="Closed<br/>Rev."

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

SortExpression="revenuerank" />


"gridView" EventName="Sorting" />


protected void load_gv(string _sproc, string _param)
{
using (FADataBase faDb = DBHelper.GetDatabase(FAUser))
{
string errorString;
try
{
DataTable dt = faDb.oneparamDt(_sproc, _param, out
errorString);
DataView dv = new DataView(dt);
gridView.DataSource = dv;
gridView.DataBind();
}
catch (dbExecException sex)
{
errorMessage(sex.ToString());
}
}
}

public void gv_OnSorting(object sender, GridViewSortEventArgs e)
{
GridView tempG = (GridView)sender;
string asdf = tempG.ID.ToString();

if ((string)ViewState["sort"] == "desc" &&
(string)ViewState["lastSort"] == e.SortExpression)
{
ViewState["sort"] = "asc";
e.SortDirection = SortDirection.Ascending;
}
else
{
ViewState["sort"] = "desc";
e.SortDirection = SortDirection.Descending;
}

ViewState["lastSort"] = e.SortExpression;
}

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 1737

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

Similar topics

0
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...
1
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...
6
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...
4
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...
4
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...
1
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...
2
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");...
4
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...
0
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.