473,466 Members | 1,406 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sorting grid

Hi all,
I have written an ASP.Net form that displays a sortable grid. I works
fine in Internet Explorer. But it gives me an error when I try to display it
in 3rd party application. The error says something like "object expected" in
the following line:
<td nowrap="nowrap"><a
href="javascript:__doPostBack('dgProposals$_ctl1$_ ctl0','')"
style="color:White;">ProposalID</a></td>
Please note that in the above line dgProposals is the grid's name and
ProposalID is the header text for a sortable column of the grid.
I think this line is the header of the sortable column. I know that the
third party application does sopport Javascript. So the question is that is
the above line actually Javascript. Is there any other way to sort the grid
so that it works in the 3rd party application that supports HTML and
Javascript?

Please help.

Thanks...
-Nikhil
Nov 18 '05 #1
1 1292
Nikhil,
You can deligate a method to handle Datagrid's sort command event. In the
method, you will sort the data before binding it to the grid. See the code
snippet below:

Private var to keep track of the sortstring:
private static string SortExpression="";

Deligate:
this.dgTest.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.dgTest_Sort);

Method:
void dgTest_Sort(Object sender, DataGridSortCommandEventArgs e)
{
if(SortExpression==e.SortExpression.ToString()) //Change the sort order
to DESC
{
SortExpression = e.SortExpression.ToString() +" DESC";
}
else //Change the sort order to ASC
{
SortExpression = e.SortExpression.ToString();
}

try
{
DataTable dtTest=Get your DataTable here;
//datasoure will be the DefaultView of dtTest Table.
DataView dv=dtTest.DefaultView;

//Sort the DataView
if (SortExpression !="")
{
dv.Sort=SortExpression;
}
dgTest.DataBind();
}
catch(Exception ex)
{
throw ex;
}

}

Good luck :)-
Prodip Saha
"Nikhil Patel" <ni********@aol.com> wrote in message
news:uW**************@TK2MSFTNGP09.phx.gbl...
Hi all,
I have written an ASP.Net form that displays a sortable grid. I works
fine in Internet Explorer. But it gives me an error when I try to display it in 3rd party application. The error says something like "object expected" in the following line:
<td nowrap="nowrap"><a
href="javascript:__doPostBack('dgProposals$_ctl1$_ ctl0','')"
style="color:White;">ProposalID</a></td>
Please note that in the above line dgProposals is the grid's name and
ProposalID is the header text for a sortable column of the grid.
I think this line is the header of the sortable column. I know that the
third party application does sopport Javascript. So the question is that is the above line actually Javascript. Is there any other way to sort the grid so that it works in the 3rd party application that supports HTML and
Javascript?

Please help.

Thanks...
-Nikhil

Nov 18 '05 #2

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

Similar topics

9
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the...
12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
1
by: Rushabh Dadbhawala | last post by:
Problem: I am fetching data from the database, storing it in a dataSet, and binding it with a Data Grid. The DataGrid controls allows sorting. The problem is that when the data is sorted on one...
7
by: Pete Davis | last post by:
A different question this time. I have a DataGrid bound to a collection. Is there any way for me to allow sorting? The DataGrid.AllowSorting=true doesn't work, but that's probably because it can't...
4
by: Mark Travis | last post by:
Hi all, I have written a simple Web Application that displays a query result onto a page using the ASP DataGrid. To Digress ======= Development information about the page is as follows 1....
1
by: puja | last post by:
hi all, am using grid view in asp.net 2.0 . My problem is easy but can't get it to work. My grid view id = grdContract and am binding grid view using dataset My dataset returns 5 columns from...
4
by: Ambica Jain | last post by:
Hi, I want custom sorting on some of the columns in the datagrid. And i am able to do the same by overriding MouseDown event. However, i need to rebind my datatable to reflect the changes in...
1
by: =?Utf-8?B?YmJkb2J1ZGR5?= | last post by:
I have a grid view that pulls data from a dbf file. I set the Allow Sorting to true and I put my code in the Sorting event. The problem is that I can't get the sorting to work so I wrote some...
1
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns...
2
by: ganesh22 | last post by:
Hi, I'm using below code for sorting,paging..but sorting is not working protected void grids(object sender, GridViewPageEventArgs e) { std= txtstd.text; gs= txtgs.text; if (std== "a") {...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
1
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...
0
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.