Monday, June 30, 2008

Tooltip in ASP.NET GridView headers

I was searching for the way show Tooltips for headers of ASP.NET GridView control without using javascript or using unnecessary overhead in code. And I found the way how to do it. When you define columns or your GridView you should use TemplateField instead of BoundField cause it's customizable. In TemplateField you can define HeaderTemplate and put there Label control with needed Tooltip. Here is the code:

<asp:GridView ID="GridView" DataSourceID="ObjectDataSource1" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField SortExpression="ShareCount">
<HeaderTemplate>
<asp:Label runat="server" Text="Nr. of Stocks" ToolTip="Total number of stocks on the market"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("ShareCount") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

.NET Format Strings

I've found great pdf document about .NET Format Strings.

Here is the sample from it.


Full document can be downloaded from John Sheehan blog :
http://john-sheehan.com/blog/wp-content/uploads/msnet-formatting-strings.pdf

Sunday, June 29, 2008

ASP.NET data binding essentials

<%# %> Syntax

ASP.NET introduces a new declarative syntax, <%# %>. This syntax is the basis for using data binding in an .aspx page. All data binding expressions must be contained within these characters. The following list includes examples of simple data binding from multiple sources:

• Simple property (syntax for a customer):
<%# custID %>

• Collection (syntax for an order):
<asp:listbox id="List1" datasource="'<%#">' runat="server">

• Expression (syntax for a contact):
<%# ( customer.First Name + " " + customer.LastName ) %>

• Method result (syntax for the outstanding balance):
<%# GetBalance(custID) %>

In the preceding examples, the inline <%# %> tags indicate where the information from a specific data source is to be placed in the .aspx page. The following data binding example uses a TextBox Web server control: <asp:textbox id="txt" text=="<%# custID %>" runat=server />

For more information about data binding syntax, see the following .NET Framework Software Development Kit (SDK) documentation:
Data Binding Expression Syntax
http://msdn2.microsoft.com/en-us/library/bda9bbfx(vs.71).aspx

Friday, June 27, 2008

WPF Beginners Guide

Sacha Barber is the great man who writes lot's of the great articles about WPF. Here is the series of his articles for beginners in WPF:

WPF: A Beginner's Guide - Part 1 of n
WPF: A Beginner's Guide - Part 2 of n
WPF: A Beginner's Guide - Part 3 of n
WPF: A Beginner's Guide - Part 4 of n
WPF: A Beginner's Guide - Part 5 of n
WPF: A Beginner's Guide - Part 6 of n

I hope this will greatly help many of you and you'll get main concepts and basics of this wonderful technology. Here is his blog: Sacha Barber blog

VS 2005 Error 1: "Could not load type..."

You can receive this error "Could not load type" error message in your ASP.NET Application, when you browse to .aspx page by using Visual C# .NET or running from local IIS.

SYMPTOMS

When you browse to an .aspx page, you may receive one of the following error messages:
Could not load type 'Namespace.Global'.
-or-
Could not load type 'Namespace.PageName'.

CAUSE

These errors occur if the .aspx page or the Global.asax page contains a reference to a code-behind module and if the application has not been built.

RESOLUTION

Use one of the following methods to build the application:
• Use the C# command line compiler (CSC.exe) to run the following command:
csc /t:library /r:System.web.dll /out:mydll.dll myfile.cs
• In Microsoft Visual Studio .NET, click Build on the Build menu.

NOTE: Microsoft Visual Basic .NET background compiles the project as soon as it is created. Because Visual C# .NET projects only background parse, you must explicitly build the application.

Steps to Reproduce the Behavior

1. Start Visual Studio .NET.
2. On the File menu, point to New, and then click Project.
3. Click Visual C# Projects under Project Types, and then click ASP.NET Web Application under Templates.
4. Right-click WebForm1.aspx, and then click View in Browser.

Materials are taken from http://support.microsoft.com/kb/306155

Wednesday, June 25, 2008

SQL Error "INSERT Failed" When You Update Table Referenced in an Indexed View

SYMPTOMS
When you run a stored procedure or SQL INSERT statement directly, which attempts to insert a row into a table that is referenced in an indexed view, the following error may occur:
INSERT failed because the following SET options have incorrect settings: 'ARITHABORT' Furthermore, this error may occur even if "SET ARITHABORT ON" is included in the batch or stored procedure that attempts the INSERT.

CAUSE
To successfully insert a row into a table that is referenced in an indexed view, the SQL ARITHABORT configuration setting must be set to ON. Furthermore, the statement that applies this configuration setting must be executed in its own batch. Because stored procedures contain only one batch, adding the statement to the procedure does not work.

MY SOLUTION
My own solution was to rebuild stored procedures and indexed used with the table you are updating.

RESOLUTION
To resolve this problem, add the following ADO code to your application after you open the connection to your database: MyConnection.Execute "SET ARITHABORT ON"
where MyConnection is a reference to the ADO connection object you are using to run the stored procedure that performs an INSERT or the SQL INSERT statement.


Material taken from: http://support.microsoft.com/kb/305333

Tuesday, June 17, 2008

New Employer

I've left Artfulbits Inc, and now I work for Euroland in Estonia as ASP.NET Developer.

Sunday, June 1, 2008

HTTP pipeline in ASP.NET 2.0.

Today I will provide you with a short reference for the steps in HTTP pipeline in ASP.NET 2.0. Some of the steps are internal and can't be subscribed by HTTP modules or global.asax:

1. Internal step to validate request. Protects against malicious attacks exploiting path canonicalization
2. Internal step to perform URL mapping (if the URL mapping feature is enabled)
3. Fire BeginRequest event
4. Fire AuthenticateRequest event
5. Fire DefaultAuthentication internal event
6. Fire PostAuthenticateRequest event
7. Fire AuthorizeRequest event
8. Fire PostAuthorizeRequest event
9. Fire ResolveRequestCache event
10. Fire PostResolveRequestCache event
11. Internal step to determine the IHttpHandler to process the current request (this is when the page compilation takes place)
12. Fire PostMapRequestHandler event
13. Fire AcquireRequestState event
14. Fire PostAcquireRequestState event
15. Fire PreRequestHandlerExecute event
16. Internal step to execute the IHttpHandler (call its ProcessRequest method) for the current request. The handler is determined at step #11
17. Fire PostRequestHandlerExecute event
18. Fire ReleaseRequestState event
19. Fire PostReleaseRequestState event
20. Internal step to perform response filtering (only if HttpResponse.Filter is installed)
21. Fire UpdateRequestCache event
22. Fire PostUpdateRequestCache event
23. Fire EndRequest event. This is the only event that is guaranteed to be fired for each request

I've found this info in Dmitryr's blog and took it from another topic, but this info will be valuable also.