ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1735
Number of posts: 3305

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
HELP! problem with DataGrid sorting Posted by dan1015 on 1 Sept 2005 at 3:51 PM
I have done whatevery I can think of but it still doesn't work....please help me

void my_SortCommand(Object sender, DataGridSortCommandEventArgs e){
BindDataGrid(e.SortExpression);
}


void BindDataGrid( string strSortField )
{
con = new SqlConnection( @"Server=Rabbit;Integrated Security=SSPI;database=pubs" );

query = "Select * from organizations order by city";

SqlDataAdapter myCommand = new SqlDataAdapter(query, con);

DataSet ds = new DataSet();
myCommand.Fill(ds, "organizations");

DataView Source = ds.Tables["organizations"].DefaultView;
Source.Sort = strSortField;

companyInfo.DataSource=Source;
companyInfo.DataBind();

}


<asp:DataGrid id="companyInfo" Runat="Server" AllowSorting="True" OnSortCommand="my_SortCommand" EnableViewState="false" HeaderStyle-Font-Bold="False" CellPadding="10" AutoGenerateColumns="False">



Anything wrong?

Report
Re: HELP! problem with DataGrid sorting Posted by Flakes on 2 Sept 2005 at 4:59 AM
: I have done whatevery I can think of but it still doesn't work....please help me
:
: void my_SortCommand(Object sender, DataGridSortCommandEventArgs e){
: BindDataGrid(e.SortExpression);
: }
:
:
: void BindDataGrid( string strSortField )
: {
: con = new SqlConnection( @"Server=Rabbit;Integrated Security=SSPI;database=pubs" );
:
: query = "Select * from organizations order by city";
:
: SqlDataAdapter myCommand = new SqlDataAdapter(query, con);
:
: DataSet ds = new DataSet();
: myCommand.Fill(ds, "organizations");
:
: DataView Source = ds.Tables["organizations"].DefaultView;
: Source.Sort = strSortField;
:
: companyInfo.DataSource=Source;
: companyInfo.DataBind();
:
: }
:
:
: <asp:DataGrid id="companyInfo" Runat="Server" AllowSorting="True" OnSortCommand="my_SortCommand" EnableViewState="false" HeaderStyle-Font-Bold="False" CellPadding="10" AutoGenerateColumns="False">
:
:
:
: Anything wrong?
:
:

I am not much in DotNEt, but:
Shouldnt this line:

query = "Select * from organizations order by city";


Be:

query = "Select * from organizations order by "+strSortField;

??





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.