By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

sorting grid

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.