473,698 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sort Grid from Column Header and Drop Down???

I posted a message on the topic earlier and thought I had it solved
but in testing have found problems. I have a Templated GridView
control on a webpage bound to an ObjectDataSourc e. There are 3
columns that are "Sortable" That sorting works fine until I add the
dropdown with a "refresh" button into the mix. The only way that I
have found to sort the grid from the dropdown requires the following
code.

When I set the e.Arguments.Sor tExpression it causes the grid to get
sorted the problem is the Grid properties do not reflect this change.
So when you next click on the grid column to sort it has the wrong
information as to which column is sorted and what direction is
sorted. So the first click on the column header the results are
unpredicable. Is there a better way to do this?

Any help would be greatly appreciated.

Thanks

dbl

protected void btnRefresh_Clic k(object sender, EventArgs e)
{
sortColumn =
Convert.ToInt16 (cboSortBy.Sele ctedValue.Subst ring(0, 1));
sortExpression =
grdUpcoming.Col umns[sortColumn].SortExpression ;

if (cboSortBy.Sele ctedValue.EndsW ith("A"))
{
sortDirection = "ASC";
}
else if (cboSortBy.Sele ctedValue.EndsW ith("D"))
{
sortDirection = "DESC";
}
else
{
throw new Exception("Inva lid sort by Value");
}
grdUpcoming.Dat aBind();
}

protected void ObjectDataSourc e1_Selecting(ob ject sender,
ObjectDataSourc eSelectingEvent Args e)
{
if (!e.ExecutingSe lectCount)
{
if (sortExpression != "")
{
e.Arguments.Sor tExpression = sortExpression + " "
+ sortDirection;
}
else
{
cboSortBy.Selec tedValue =
GetSortColumnIn dex().ToString( ) +
grdUpcoming.Sor tDirection.ToSt ring().Substrin g(0, 1).ToUpper();

}
}
}

Apr 11 '07 #1
0 1161

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

Similar topics

1
5980
by: Josh | last post by:
Caution, newbie approaching... I'm trying to come up with a very simple Tkinter test application that consists of a window with a drop-down menu bar at the top and a grid of colored rectangles filling the remainder of the window. Mind you, this is a contrived test application to help me understand Tkinter and Python, not an actual application yet. I've trivially subclassed Tkinter.Canvas into ColorCanvas, added a bunch of ColorCanvases...
0
1773
by: owyn | last post by:
Think of a Drop Down List in a template column in a data grid in the Edit Template. In the Item template there is a label whose: text = '<%# DataBinder.Eval(Container.DataItem, "FieldName")%>' The FieldName comes from the table that the data grid is bound. What would be neat would be to be able to fill the Data Value Field and the Data Text Field of that Drop Down List from a pick list that is passed as a data table form a class. In other...
1
2689
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting, paginantion or accepting the add and remove item events. What i am observing is that none of the vents are happening... (Sort, page, or item). I am sure I am missing something basic here... Need help... Thanks much
1
2152
by: Joe Dunleavy | last post by:
Hi Guys, Hopefully some one will have come across this issue already. I have a DataGrid inside a Div where a scroll bar displays once a certain height is meet --> <div id="dvSales" style="height: 230px; overflow: auto; width: 100%" runat="server"> The Data Grid has AllowPaging is set to False and the HeaderStyle tag is set for the DataGrid so that the header remains fixed when we scroll using the
2
4045
by: shuckjunkmail | last post by:
It was suggested that I re-submit this question as a new post rather than adding onto an old and unanswered post. The basic problem has to do with the .NET datagrid and sorting. I am having trouble getting the correct row of data from the datagrid immediately after re-sorting the datagrid. I am using the dataview for accessing the data and am using the following code as previously mentioned in a different post: Dim bm As...
1
7127
by: ECD | last post by:
Hello all, I can usually find solutions to my .NET problems by searching these groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0 framework). I want to disable sorting on the first column in the grid only. I havent found a way to reliably do this yet. I tried putting the following code in the datagrid's mouse down event Dim hti As DataGrid.HitTestInfo
4
10917
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
For performance reasons i can not set a sort order on a dataset returned from a stored procedure. Ideally in the sp i'd set the company name as the order and just load the gridview, however the joins are very complicated and this causes the sp to take 20 time (at least) longer than when no ordering is specified. I would create a temp table and sort this for the return, however, ado.net can not see a temp table because it does not exist at...
2
4416
by: Rick | last post by:
VS 2005/Pro I'm using a DataGridView in a Windows form and allowing the user to sort the columns by clicking on the header column. Is there some method offered by the grid to return back to the unsorted view? I think I could "roll my own" by resetting the bindingsource.sort = nothing, but it seems like the datagridview should have something like this?
7
30573
by: ncsthbell | last post by:
Working on converting some old MS2000 access applications to MS2007. I have many datasheets in the application and I have noticed that on all of them the column headers have a down arrow with sort/filter options. This arrow is covering up some of the letters on the column descriptions. I have built-in listboxes on my forms that allow the users to select the criteria they need so I do not need the drop down sort/filters on the columns. My...
0
8668
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
9152
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9014
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
7708
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...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4358
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3037
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
3
1995
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.