»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 sortDatagrid 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 += " ";
}
}
} |
|