DataGrid Nirvana
Last night us RDs went to a traditional North African sheesha (looks like a fancy bong) bar to smoke fancy tobacco. We even got Andrew Brust to smoke out of it (apple flavored tobacco)! All done with my sessions, so Goksin and I will go visit historic Carthage.
North African developers love the ASP .NET DataGrid. My session, Asp .Net DataGrid Drill Down (Code and Slide Download) was so much fun and fun was had by all. The sorting code went over very well. here is the code we spent the most time on:
private
{
//SQL String that will be used
string strSQL = "Select * From Customers";
//the Order By
string strOrderBy = "ASC";
//See what the viewstate has for the sortfield and ASC/DESC
if (e.SortExpression.ToString() == ViewState["sortField"].ToString())
//a match, see if ASC or DESC
strOrderBy = ViewState["sortDirection"].ToString();
//now toggle the viewstate for later
switch (strOrderBy)
case "ASC":
ViewState["sortDirection"] = "DESC";
break;
case "DESC":
ViewState["sortDirection"] = "ASC";
}
else
//New Field, so it will be ASC by default, so make DESC
ViewState["sortField"] = e.SortExpression.ToString();
//SQL statement compelted
strSQL = strSQL + " " + " ORDER BY [" + e.SortExpression + "] " + strOrderBy;
//set the grid to the first page before you resort
DataGrid1.CurrentPageIndex = 0;
//call the FillGrid method to rebind the grid w/ new OrderBy
FillGrid(strSQL);
Page rendered at Tuesday, August 16, 2022 12:29:03 PM (Eastern Daylight Time, UTC-04:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.