473,322 Members | 1,703 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,322 software developers and data experts.

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_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.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.WebControls.Image img = new
System.Web.UI.WebControls.Image();
// setting the dynamically URL of the image
img.ImageUrl = "~/img/ico_" + (GridView1.SortDirection
== SortDirection.Ascending ? "asc" : "desc") + ".gif";
// checking if the header link is the user's choice
if (GridView1.SortExpression == lnk.CommandArgument)
{
// 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 1195

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

Similar topics

10
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
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...
1
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...
0
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...
1
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>...
56
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...
3
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...
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...
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: 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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.