473,770 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview sorting problem

Hi:

I am using a grid and having a problem with sorting. Below are my
code and change the header name at run time as below based on
language.If i don't change the header name it work. Can someone please
help me so that i can enable the sorting and change the header as
well. Thanks, in advance.
<asp:GridView ID="GridView1" CellPadding="5"
EmptyDataText=" No Data Found" GridLines="Vert ical"
ShowFooter="Tru e" CssClass="gridv iew"
AlternatingRowS tyle-CssClass="even" Width="620px"
runat="server" AutoGenerateCol umns="False"
DataSourceID="O bjectDataSource 2" AllowSorting="t rue"
OnDataBound="Gr idView1_DataBou nd"
OnRowDataBound= "GridView1_RowD ataBound"
OnRowCreated="G ridView1_RowCre ated"
EnableViewState ="true">
<Columns>
<asp:BoundFie ld HtmlEncode="Fal se" HeaderStyle-
VerticalAlign=" Top" DataFormatStrin g="{0:C4}"
DataField="GRAN T_PRICE"
SortExpression= "GRANT_PRIC E" ItemStyle-HorizontalAlign ="right" />
<asp:BoundFie ld DataField="GRAN T_DATE"
HeaderStyle-HorizontalAlign ="Right" HeaderStyle-VerticalAlign=" Top"
ItemStyle-Wrap="false"
SortExpression= "GRANT_DATE " ItemStyle-HorizontalAlign ="right" />
<asp:BoundFie ld DataField="PLAN _ID"
HeaderStyle-VerticalAlign=" Top" SortExpression= "PLAN_ID" />
<asp:BoundFie ld DataField="AGGR EMENT"
HeaderStyle-VerticalAlign=" Top" SortExpression= "AGGREMENT" />
<asp:BoundFie ld DataField="BALA NCE_OPTIONS"
HeaderStyle-VerticalAlign=" Top" SortExpression= "BALANCE_OPTION S"
ItemStyle-HorizontalAlign ="right" />
</Columns>
<AlternatingRow Style />
</asp:GridView>

<asp:ObjectData Source ID="ObjectDataS ource2"
runat="server" SelectMethod="G etDetail"
TypeName="cBMOS OP">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="clie ntIDH"
Name="clientID" PropertyName="V alue"
Type="String" />
<asp:ControlPar ameter ControlID="base IDH"
Name="baseID" PropertyName="V alue" Type="String" />
</SelectParameter s>
</asp:ObjectDataS ource>
protected void GridView1_RowCr eated( object sender,
GridViewRowEven tArgs e )
{
if ( e.Row.RowType == DataControlRowT ype.Header )
{
e.Row.Cells[0].Text = lblGrantPrice.V alue;
e.Row.Cells[0].ColumnSpan = 2;
e.Row.Cells[0].HorizontalAlig n = HorizontalAlign .Right;
e.Row.Cells[1].Text = lblGrantDate.Va lue;
e.Row.Cells[1].HorizontalAlig n = HorizontalAlign .Left;
e.Row.Cells[2].Text = lblPlanID.Value ;
e.Row.Cells[2].HorizontalAlig n = HorizontalAlign .Left;
e.Row.Cells[3].Text = lblAggrementRec eived.Value;
e.Row.Cells[3].HorizontalAlig n = HorizontalAlign .Left;
e.Row.Cells[4].Text = lblAvailableSha res.Value;
e.Row.Cells[4].HorizontalAlig n = HorizontalAlign .Right;
e.Row.Cells[5].Text = lblOptionToExer cise.Value;
e.Row.Cells[5].HorizontalAlig n = HorizontalAlign .Right;
}
}

Apr 25 '07 #1
0 1414

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

Similar topics

0
2736
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 not the whole page, but a portion of the page. Strangely enough the URL below http://beta.asp.net/QUICKSTARTV20/aspnet/doc/ctrlref/data/gridview.aspx (VB GridView Paging and Sorting Callbacks example)
5
3377
by: yefei | last post by:
In my web design, I display records from a SQL DataBase according to some filters the GridView is defined with select commands and selest parameters however, I also want to display all records in the database when the user press a "View All" button. In this case, I need to change the select comand and clear the parameters. And I did this in the button_click() event. the GridView can display desired results when I press the "View All"...
4
8252
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 = ds gvUsers.DataBind()
4
5481
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 an eventhandler thus: Protected Sub grdResult_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles grdResult.Sorting
0
1768
by: jobo | last post by:
Hey there, I'm having a problem getting sorting to work. Here's what the GridView looks like: "server" ID="updt1" Mode="Conditional">
12
3815
by: Cindy Lee | last post by:
When I do a sorta on 1 table, then the other table goes back to the original order. What can I set so, it keeps the order of the other current gridview's order. I set all the gridview values in my 'onpageload' in the cs file.
4
11163
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 ReportTable As System.Data.DataTable = New System.Data.DataTable("SendTo") The ReportTable is populated row by row by data gotten back from the
2
1384
by: mahesh123 | last post by:
Hi, I am using gridview in my form and binded the gridview with object datasource.I am trying to implement sorting for my grid view and i am getting following error.i am using asp.net with VB Server Error in '/' Application. -------------------------------------------------------------------------------- The data source 'objdsDataSource' does not support sorting with IEnumerable data. Automatic sorting is only supported with...
0
1531
by: Sobin Thomas | last post by:
Hi All, How can I bind the Gridview control to Sql Datasource control on a button click(I see majority of the articles binding datasource at page load) I need to enable the paging and sorting of the Gridview control also .Actually I am able to bind the sql datasource control to the Gridview on button Click but on clicking the GridView for paging or sorting , the Gridview vanishes!! In short, I want to bind the GridView control to a...
1
2024
by: Sobin Thomas | last post by:
Hi All, How can I bind the Gridview control to Sql Datasource control on a button click(I see majority of the articles binding datasource at page load) I need to enable the paging and sorting of the Gridview control also .Actually I am able to bind the sql datasource control to the Gridview on button Click but on clicking the GridView for paging or sorting , the Gridview vanishes!! In short, I want to bind the GridView control to a...
0
9618
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
9454
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
10260
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...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8933
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
7456
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
6712
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();...
1
4007
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
2850
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.