17 May 2008

SSIS: Passing parameters from parent to child package

When using “Execute Package Task” in SSIS control flow, you can’t pass in any configuration options or variables to the child package. Here is a workaround to do that:

  1. In the parent package, create a variable for each variable you want to set in child package. It must be defined as a global variable.
  2. In the child package, create variables to correspond to the ones you created in the Parent package (e.g. “ChildVar” to correspond to “ParentVar”). Important: assign these variables valid default values, otherwise you will not be able to run the child package standalone.
  3. In the child package, open the package Configurations. Add a new configuration, and select the “Parent package variable”. Enter the variable name you added to the parent package (in our example “ParentVar”). Note that variables are case sensitive. Assign this to the variable of the child package (”ChildVar”).

Now when you run the parent package, it will pass the value of the “ParentVar” to the “ChildVar”. When you run the child package directly (without a parent package), it will use the default value of the “ChildVar”.

03 May 2008

A bug in ASP.Net 2.0 Gridview control and ...

I don’t know why it has to be like this! I know BUG is a non-detachable part of software development and according to a Murphy’s law: "Each computer code has five bugs, and this number does not depend on how many bugs have been already found." (!?)

But, when a bug was found and reported to a company like Microsoft, why it should take so long to fix it? And isn't it better if Microsoft add a note or comment in MSDN like: "this is a known bug and here is the workaround..." so that people don't get confused by getting a different result from a sample code? Or maybe Bill Gates wants to make developers more creative?!

To make the long story short, last week after several frustrating hours debugging a Gridview image button which was firing an command event twice, I found it's a known bug in ASP.Net 2.0 and was reported to Microsoft on 2006, and yet to be fixed! The funny thing is it works fine when you have a LinkButton instead of ImageButton.

I finally found a workaround for this:

Put your imagebutton in an ItemTemplate and add:

The rest is same as other Gridview commands, you need to write your code in RowCommand event of the Gridview and find the index of the row like this:

Dim index As Integer = Convert.ToInt32(e.CommandArgument) Dim myRow As GridViewRow = CartGrid.Rows(index) If (e.CommandName = "YourCommandName") Then ....

Have a look at this page, (a frustrated developer was trying to get help about this issue and answer of Microsoft Online Support...):

http://www.netnewsgroups.net/group/microsoft.public.dotnet.framework.aspnet/topic16694.aspx