473,657 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sort expression always = "" in gridview... why?

I'm trying desperatly to add a sort order arrow to my grid view and have
this code below ofr it... but when the code runs the girdview sortexpression
is always = "" never the sort name... why?! i want the image to show up on
only the column sorting on...

protected void GridView1_RowCr eated(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.Header)
{
foreach (TableCell tc in e.Row.Cells)
{
if (tc.HasControls ())
{
// search for the header link
LinkButton lnk = (LinkButton)tc. Controls[0];
if (lnk != null)
{
// inizialize a new image
System.Web.UI.W ebControls.Imag e img = new
System.Web.UI.W ebControls.Imag e();
// setting the dynamically URL of the image
img.ImageUrl = "~/img/ico_" + (GridView1.Sort Direction
== SortDirection.A scending ? "asc" : "desc") + ".gif";
// checking if the header link is the user's choice
if (GridView1.Sort Expression == lnk.CommandArgu ment)
{
// adding a space and the image to the header link
tc.Controls.Add (new LiteralControl( " "));
tc.Controls.Add (img);
}
}
}
}
}
} every time that executes the sort expression is = "" never the command
argument.....
Jun 28 '06 #1
0 1208

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

Similar topics

10
2202
by: Derek Basch | last post by:
Hello, I have a string like: string = "WHITE/CLARET/PINK/XL" which I need to alter to this format: string = "WHITE-CLARET-PINK/XL"
0
1106
by: Morten | last post by:
Hi! I'm using a gridview to display properties for a number of custom made objects. E.g. "firstname" and "lastname" of a user object. I'd like to be able to sort my object list based on which header the user clicks. The built-in functionality to do this isn't avaliable so I guess I'll have to write some code to do this. Could someone provide an example of the code that I need to add to the Sorting event handler to have my gridview sort...
1
1450
by: keithb | last post by:
I have a working ASP.NET 2.0 application that uses a GridView control. How can I enable the feature that allows a user to click on a column heading and sort the contents by the information in that column? Thanks, Keith
0
4816
by: rmgalante | last post by:
Hi, I've been experimenting with the ASP.Net GridView and encountered some interesting issues that I thought I would share. I have a page that loads a GridView with a generic collection of objects. For the purposes of this discussion, the objects define a Customer, and have an id and a name. I want to sort these customers by id or by name in ascending and descending order. Here is what I did to make it work.
1
5367
by: trint | last post by:
i have this in the html view: <asp:TemplateField HeaderText ="Remove?"> <ItemTemplate> <asp:CheckBox ID="removeSelect1" runat="server" /> </ItemTemplate> <HeaderTemplate> </HeaderTemplate> <HeaderStyle ForeColor="White" /> </asp:TemplateField>
56
6716
by: Adem | last post by:
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15) says under 6.4.2(2) : case constant-expression : I propose that the case expression of the switch statement be changed from "integral constant-expression" to "integral expression".
3
5233
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use DataTable, I am using List of Objects. Here's one example: http://ryanolshan.com/technology/gridview-without-datasourcecontrol-datasource/
0
8315
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8734
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
8608
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
7341
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
6172
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
5633
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
4164
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...
1
2733
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
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.