Posts

Showing posts with the label Random How-To

Hiding an ASPXGridView Delete button with HTMLRowCreated vs. CommandButtonInitialize

It's pretty typical in Administration forms to need to hide buttons on certain rows for various reasons. Particularly it is nice to hide the Delete button if in fact the row in question is being used in other places in the app. This is a nice feature to let the user know up front that the row in question is in use, rather than them trying to delete it and getting a foreign key related error after the fact. For years now in DevExpress ASPxGridView's I have been handling this in the HtmlRowCreated event. And I have been doing it wrong. Before: protected void gridGiftCodes_HtmlRowCreated ( object sender, DevExpress.Web.ASPxGridViewTableRowEventArgs e) { if (e.RowType == GridViewRowType.Data){ int commandColumnIndex = - 1 ; //Find the command column commandColumnIndex = e.Row.Cells.Count- 1 ; //assume it's the last visible colum //Get the command cell for this row GridViewTableCommandCell cell = e.Row.Cells[commandColumnIndex] as Gri...

Log4Net Primer

My notes on Log4Net, which is a great logging utility I've been using in a lot of console apps lately. It's beautiful. References: Great Introduction Video by Tim Corey - the first 45 minutes were sufficient for me: https://www.youtube.com/watch?v=2lAdQ_QwNww&feature=youtu.be Tim Corey’s original article: http://www.codeproject.com/Articles/140911/log-net-Tutorial Official Documentation, very thorough: http://logging.apache.org/log4net/index.html Summary: log4Net is a great logging tool for .Net applications. You can log at different “levels” like Debug, Info, Warn, Error, Fatal, and send different levels of logging to different places. For example all messages could go to the console, but Error or Fatal messages can go to a log file or a database. The basic steps are: Add log4Net to your program via NuGet Configure log4Net settings in your App.config Configure various “appenders” for all the targets you want to log to, and what format of ...