Posts

Delete Command Twice in GridView

Image
The delete command is being called twice for each click on delete. What do I mean by this? With this code: <asp:GridView runat= "server" DeleteMethod= "DeleteRowById" ...> <asp:CommandField ShowDeleteButton= "True" /> </asp:GridView> I am getting the DeleteRowById method called which when the delete button in the CommandField is clicked. Doing some Internet research I found this: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=105123 However, the workaround isn't right, basically all you need to do is change the <asp:CommandField to: <asp:TemplateField> <ItemTemplate> <asp:ImageButton runat=server id= "ImageButton1" CommandName= "Delete" ImageUrl= "..." CommandArgument='<%# DataBinder.Eval(Container, "RowIndex" ) %>' /> </ItemTemplate> </asp:TemplateField> You don't need to add a code behind...

Shutting Down a Running COM+ Instance

Image
If you have an instance of object running under COM+ (in the dllhost.exe process space) and you want to shut it down from C#, you can use the code below.  Note that ShutdownApplication only intializes the shutdown of the COM+ applicance, it will return sometimes before the application is finished shuting down.  So you need to check to make sure the applicatio is shut down before continue.  I use this code in my unit testing to kill the instance-- making sure that it is stateless.  Also note that you need to send the package id for the application -- this is the guid you used when installing the application into COM+.  It can be found on the first property page of the application properties in component manager. internal static void ShutDown() { Int32 count = 0; COMAdmin.COMAdminCatalog objAdmin = new COMAdmin.COMAdminCatalog(); // WWB: ShutDown The Application (All Instances) Using teh Package Id objAdmin.ShutdownApplication(Configuration...

Mesh and IE Favorates

Image
I have been playing around with Mesh a bit of late. Mostly good other than on a few of my machines, Mesh refused to install. Either the install itself failed or it just never allowed me to sign in. But, I figured out one use for Mesh this morning that made it all come together: sharing IE Favorites. After installing Mesh, share the following folder on each machine: Xp, 2003: C:\Documents and Settings\%USERNAME%\Favorites\Links Vista, 2008: C:\Users\%USERNAME%\Favorites\Links Make sure when resolving the share location of the folder on subsiquent machines, you browse to the location above. Now your IE links are synced across machines.  

Vista Administrator

In Vista there is an Administrator account, however it is disabled on install. If you join the domain you can login with any domain user you want, however if your domain connection is lost, your computer account or the domain lost then you can only login with the local user you created at install -- which can't be the Administrator. If you forget the the password to this user there is a problem. So to prevent a reinstall you need to enable the Administrator account with this: Net user administrator /active:yes at the command line under elevated permissions (Run As Administrator). The administrator password is blank (which means you don't have to login) by default. {6230289B-5BEE-409e-932A-2F01FA407A92}

Azure Storage - CloudDrive SDK

If you are the CloudDrive Powershell extension in the CTP of Azure Storage SDK, the easiest way to map a drive onto the cloud is to add this line to the MountDrive1.ps1 file: MountDrive -ServiceUrl "http://blob.core.windows.net" -DriveName "BigDrive" -ProviderName "BlobDrive" -Account "accountName" -Key "XXXXXXXXXX" Note that the accountName is the name of your project on the Azure web site, the storage project name. And the Key is the primary key you are given from the Azure web site. Also, the SeriveURL doesn't contain your account name at the beginning. Once you have this line added to the bottom of the file and save, you can run the runme.cmd batch file from the command line and your drive will be mapped. The other two lines look like this: MountDrive -ServiceUrl "http://127.0.0.1:10000" -DriveName "Blob" -ProviderName "BlobDrive" MountDrive -ServiceUrl "http://127.0.0.1:10001" -DriveName ...

varchar(max) and varbinary(max) Questions and Answers

Image
How big of an allocation does max represent in the case of varchar(max) and varbinary(max)? 2 ^ 31 - 1 bytes or just about 2gb. Can I specify a varchar(9000) or varbinary(12000)? No.  If you are going to specify an actual number instead of (max) then your limit is 8000.  The size can be 1 to 8000, or max, there is nothing between 8000 and max. Is a varchar(max) or varbinary(max) column stored in the data row? If the size of the varchar or varbinary item is less than 8000 then it is stored in the data row.  If it is greater than 8000 then the item is moved out of the data row into a special storage location for large objects. Should varchar(max) be used to replace the TEXT column type? Yes.  varchar(max) can handle larger strings than the text type can.  varchar(max) is easier to update than text with standard SQL statements.

Mutual Exclusive CollapsiblePanelExtender

The following piece of code will allow you to have multiple ASP.NET 2.0 Ajax CollapsiblePanelExtender controls on a single page and only one of them will be expanded at a time. You can use this to keep the page length short. You must set the BehaviorId of the CollapsiblePanelExtender, that is what the $find javascript function looks for. Make sure to add all the BehaviorIds to the array in the pageLoad function. <script type= "text/javascript" > // WWB: Handles Mutual Exclusive Expansion. Only One Extender Panel // Can Be Open At A Time var extenders = []; function pageLoad(sender, args) { extenders[0] = $find( "PanelExtender1" ); extenders[1] = $find( "PanelExtender2" ); extenders[2] = $find( "PanelExtender3" ); // WWB: Hook All The Extenders, If extenders[i] is null then // the extenders is not being displayed -- i.e. not visible for (var i=0; i< extenders.length; i++) if (extenders[i] !...