C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




datagrid.sort () is not working


Posted Date: 05 Jul 2008      Total Responses: 1

Posted By: Lalit...wait for ANS       Member Level: Gold     Points: 1



datagrid.sort () is not working.Means data now display,but not in sorted form.When i use the assendin as well as dessending, it shows same data formate




Responses

Author: mahalakshmi    05 Jul 2008Member Level: GoldRating:     Points: 6

use SortExpression to sort datagrid data or use ORDERBY in sql.


try the follwing code but i have sent code for sorting gridview data ,u can change gv to dg,

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)

{


//string s = GridView1.SortExpression;


//e.SortExpression = s;


SqlDataAdapter da1 = new SqlDataAdapter ("Select * from product",con);


DataTable dt = new DataTable();



da1.Fill(dt);


DataView dv = new DataView(dt);




//dv.Sort


// GridView1.DataSource = dv.Sort;


//GridView1.DataBind();

dv.Sort = e.SortExpression +
" " + "ASC";

GridView1.DataSource = dv;

GridView1.DataBind();

}




Post Reply
You must Sign In to post a response.
Next : how to sort GridView data?
Previous : Problem in playing playing the video file in mozilla firefox
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use