Showing posts with label ASP. Show all posts
Showing posts with label ASP. Show all posts

Wednesday, July 2, 2008

More information about ASP.NET Page life-cycle and common events

I’ve found wonderful document about ASP.NET Page lifecycle events on http://john-sheehan.com/blog. Little information about general page Life-cycle stages and events:
life

The whole document can be found here: http://john-sheehan.com/blog/wp-content/uploads/aspnet-life-cycles-events.pdf . There is also information about Data Binding Events for Data-Bound Controls and Common Life-cycle Events.

Enjoy :)

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>

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