Posts

Showing posts with the label vb.net programming

Proper way to calculate CAGR using T-Sql for SQL Server

Image
After reading (and attempting the solutions offered in some) several articles about SQL and CAGR,  I have reached the conclusion that none of them would stand testing in a real-world environment. For one thing, the SQL queries offered as examples are overly complex or don't use the correct math for calculating proper CAGR. Since most DBAs don't have an MBA or Finance degree, let me help.  The correct equation for calculating Compound Annual Growth Rate (as a percentage) is:  Some key points about CAGR:  The compounded annual growth rate (CAGR) is one of the most accurate ways to calculate and determine returns for anything that can rise or fall in value over time. Investors can compare the CAGR of two alternatives to evaluate how well one stock performed against other stocks in a peer group or a market index. The CAGR does not reflect investment risk. You can read a full article about CAGR  here .  To calculate the CAGR for an investment in a language like ...

Getting the text of a GridView HyperLink Bound Field

It's quite common to do some extra processing of data during a GridView's Row_DataBound event. You can normally capture the value of the GridView cell like this, which would capture the value of the 3rd column in the grid (row count is 0 based).  If e.Row.RowType = DataControlRowType.DataRow Then     Dim Value as String = CType(e.row.cells(2).Text, String)     'some manipulation of cell data, such as formatting, etc.     e.row.cells(2).Text = NewValue End If This works well if the field is configured as a BoundField:  <asp:BoundField DataField="DataBaseFieldValue" HeaderText="Field Name" /> But if the field is configured like this, as a HyperLink field, then you must get to its value differently: <asp:HyperLinkField DataTextField="Symbol" HeaderText="Symbol" DataNavigateUrlFields="StockID"   DataNavigateUrlFormatString="EditStock.aspx?id={0}&ref=pp" SortExpression="s.symbol" /> This assume...