ReportViewer Horizontal Scrollbar not appearing

by rBellantoni 9/24/2009 7:05:00 AM

Sometimes the horizontal scrollbar renders so to bring it back into view you need to add this style:

 

ReportViewer.Style.Add("margin-bottom", "26px")

Then it will show up!

Tags: , , , ,

GridView Format boundcolumn as Shortdate

by ebarcza 9/24/2009 4:23:00 AM

<asp:BoundField DataField="PeriodStart" HeaderText="Start" DataFormatString="{0:d}"/>

Tags:

SQL Divide by Zero

by ebarcza 9/23/2009 7:40:00 AM

T-SQL Avoid Divide by Zero errors

Sometimes you can't help it -  zeros appear in the denominator of formulas in a stored procedure or function, take care of them by using the nullif function to null them out NULLIF ( expression1 , expression2 ) 

Returns a null if Expression1 and Expression 2 are equal
EX: nullif(@MyValue, 0)

Tags:

SQL SERVER

Workaroud for XmlSiteMapProvider requires that sitemap nodes have unique URLs.

by ebarcza 9/18/2009 5:23:00 AM

I like to have the same menu options is differnet places for ease of use but .NET XmlSiteMapProvider wont let you have the same url in a sitemap

workaround: put a fake querystring at the end of one of them

<siteMapNode title="sample" description="sample" url="/sample.aspx?id=1" />

<siteMapNode title="sample" description="sample"url="/sample.aspx" />

Works like a Chahm!!  (we live in the northeast - no r's Cool)

Tags:

CSS Visibility Vs Display

by rBellantoni 9/16/2009 12:32:00 PM

These are often confused and people are unsure of which one they should use, but the key difference between the two is that Visibility merely hides whether you can see the element or not, the element is still actually taking up space on the page you just can't see it. The Display property when set to none will actually take the element out of the layout of the page so it does not take up space at all.

Tags:

Looping through GridView with Javascript on the client side

by rBellantoni 9/16/2009 12:24:00 PM

Every had to find a specific control inside of a gridview on the client side or grab a group of controls to manipulate them. Here is how to grab controls in the gridview with javascript:

function GetTotal() {
            totalDTH = 0;
            totalMCF = 0;

            // Get the gridview
            var grid = document.getElementById("<%= grdVolumes.ClientID%>");

            // Get all the input controls (can be any DOM element you would like)
            var inputs = grid.getElementsByTagName("input");

           // Loop through all the DOM elements we grabbed
           for (var i = 0; i < inputs.length; i++) {

                // In this case we are looping through all the Dek Volume and then the Mcf volume boxes in the grid and not an individual one and totalling them
                if (inputs[i].name.indexOf("txtDekVolume") > 1) {
                    if (inputs[i].value != "") {
                        totalDTH = totalDTH + parseInt(inputs[i].value);
                    }

                }
                if (inputs[i].name.indexOf("txtMcfVolume") > 1) {
                    if (inputs[i].value != "") {
                        totalMCF = totalMCF +  parseInt(inputs[i].value);
                    }

                }
            }
        }

Tags:

The difference between Convert and TryParse ASP.NET

by rBellantoni 9/16/2009 11:55:00 AM
The difference between Convert and TryParse is that Convert, is just int.Parse that checks for a null value and then converts it to 0. So a Convert will not break if it is passed a null it will however through a cast exception if a non-numeric character is passed in. TryParse however will not throw a cast exception, it returns an output variable with the successfully casted variable or default value (depending on the type, example: int.TryParse will return a 0 when it is not a valid number) the function also returns a boolean whether the string was parsed correctly or not. See the example code below:

if (int.TryParse(txtText1.Text, out testInteger) == false)

{

testInteger = 0;

}

Here we check to see if the try parse failed if it did we set the integer to 0, otherwise the parsed value is outputted right to the variable and no other code is required.

Tags:

DOTNET renaming a control takes forever

by ebarcza 9/16/2009 11:46:00 AM

This is annoying as all hell. When you rename a control in .NET using the properties window... it takes forever, which is way too long.

It takes so long because Visual Studio uses a process called rename-refactor which renames all the occurrences of the selected control throughout the whole project. It is especially annoying when its a new control on the page and you rename it from it's default name ie "textbox1" to something meaningful - "txtMeansAlot" and it takes 5 minutes to finish. Gimme a break!

I just want to rename the sucker and continue coding. The sure fire way around this is to just rename it in source code mode, but apparently there's a hot fix located here:http://support.microsoft.com/kb/939520. Comment if it works for anyone.

Tags:

.NET

Canceling Application.Ontime in excel

by ebarcza 9/16/2009 5:43:00 AM

So I'm a little new with excel, but programming in VBA is fun so I took on a little project involved consuming data from a webservice. The workflow went like this:

  1. Poll web service
  2. Drop new records in designated named range
  3. Run again in 30 seconds

I scheduled a subroutine to perform this using Application.Ontime. The problem was, when i closed the workbook, it kept on opening the workbook back up. So I had to figure out a way to cancel the scheduled subroutine. You do this by setting schdeule=false, but you have to pass in the same time that it was schedule for in the earliest time param. Here's how you do it:

 

Public RunWhen As Double - I put this in a module called mPublic 

Private Sub Workbook_Open()
    Time_set
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Bye_Bye
End Sub

Sub Time_set()
    RunWhen = Now + TimeValue("00:00:30")
    Application.OnTime RunWhen, "time_set"   
    DoWork

End Sub 

Sub Bye_Bye()
     Application.OnTime EarliestTime:=RunWhen, Procedure:="time_set", Schedule:=False

End Sub

Rate this post to let me know if it actually helped anyone!

 

 

Tags:

Excel Programming

C# - Changing font Color in Codebehind

by ebarcza 9/14/2009 10:01:00 AM

real simple 

lblSystemMessage.ForeColor = System.Drawing.Color.Red;

you'll get instellisense on System.Drawing.Color that will give you a pick list of system colors.

 Enjoy!

Tags:

.NET

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  November 2017  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Recent comments

Tags

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017

Sign in