Stephen Forte's Weblog
A complete waste of time…

 



Subscribe to "Stephen Forte's Weblog" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 

 

  Monday, June 02, 2003


Dallas, Texas. (Speaking at Tech*ED)

Recovering from the Regional Director party last night. Did way too much karaoke with Steve Lasker, Jon Box and Scott Stanfield. We had some good fun. I did decide that Scott Hanselman is not as cool as I thought, he backed out on some of my pranks. Clemens Vasters on the other hand is lots of fun and will party hard at Tech*ED in Europe and Asia as well as Africa.

Day 1 of TechED was good so far. Started with a morning run and then attended Adam Cogan's session on SQL Server and hung out and caught up in the speakers lounge. Proctered the SQL CE lab and then head off to a dinner with MSFT SR. VP Paul Flessner. I speak on Wedneday and Thursday, so I need to get my demos up and running!

I rewrote some examples. Here is some code to toggle the color of a cell in a DataGrid based on the data presented:

public void ToggleYellow(object sender, DataGridItemEventArgs e)

{

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)

{

//get the data that is in the current record

if (e.Item.Cells[2].Text == "Sales Representative")

{

//make the cell yellow

e.Item.Cells[2].BackColor = System.Drawing.Color.Yellow;

}}}

 

Here is a custom sorting routine:

private void SortGrid(object source,DataGridSortCommandEventArgs e)

{

//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";

break;

}

}

else

{

//New Field, so it will be ASC by default, so make DESC

ViewState["sortField"] = e.SortExpression.ToString();

ViewState["sortDirection"] = "DESC";

}

//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);

}


5:40:45 PM    


Click here to visit the Radio UserLand website. © Copyright 2003 Stephen Forte.
Last update: 7/30/2003; 1:40:34 PM.

June 2003
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
May   Jul