Home | Articles|Namespace|Interview Questions|Tools|Jobs|Projects|Community
Asp.net Tutorials

»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books

»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects

»Competition
Community
Winners
Prizes
Write For Us
Members

»Other Resources
Links
Dotnet Resources

How to create a Sorting arrow in the datagrid sort

Datagrid does not come with a deafult sort arrow so we have to show our own this code does just that

//call this code in the grid where you call the datagrid bind function
//UpdateColumnHeaders(DataGrid,SortText) eg SortText = "ID ASC"
private void UpdateColumnHeaders(DataGrid dg,TextBox txt)
{
foreach (DataGridColumn c in dg.Columns)
{
string[] arrSort = new string[1];
arrSort = txt.Text.Split(' ');
c.HeaderText = Regex.Replace(c.HeaderText, "\\s<.*>", string.Empty);
if (c.SortExpression == arrSort[0])
{
if (arrSort[1]=="ASC")
c.HeaderText += " ";
else
c.HeaderText += " ";
}
}
}

Have a Question and dont know the answer post it below and get answers in minutes

Due to spam this feature is disabled
To get answers fast , make sure you enter a detailed subject for example: "DataGrid issues need answer" not "DataGrid"

Subject:

Catjegory Name:

Message:



© 2008 dotnetwatch.com -- Privacy policy