473,320 Members | 1,990 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,320 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 1739

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...
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.