Count aggregate
27 February 2008 Tips
Bubble image
I wanted to show the number of listings in a particular category. After some research and reading Scott Mitchell's book ASP.NET Data Web Controls, I came up with the following solution.

Code behind page under the Page_Load event

Dim cnn As New SqlConnection
cnn.ConnectionString = _
"Data Source = yourDataSource;" & _
"Initial Catalog = yourDatabase;" & _
"Integrated Security = SSPI"

Dim da As SqlDataAdapter
da = New SqlDataadapter(

SELECT category, COUNT(*)
FROM myTable
GROUP BY Category ", cnn
)

Dim ds As New DataSet
da.Fill(ds,"Category")

dlCategory.DataSource = ds
DataBind()

Then on the html page

<asp:DataList ID="dlCategory" runat="server">

<itemTemplate>
<a href ='Categories.aspx?cat=<%#  Eval("catergory")  %>'>
<%# Eval("category") %>
<%# Eval("categoryCount") %></a>
</itemTemplate>

</asp:DataList>

And so now if you look under the categories column on the right a count is displayed against each of my categories. All that remains for me to do now is an Archive and the Search
Uneven columns
22 February 2008 Tips
Bubble image
One of the problems with floating containers is that they will generally only extend to the depth of their content. Imagine therefore that you have two div's side by side within a containing div it can be very hard to create the illusion of columns using background colours alone.

The solution is to use a background image that gives the illusion of columns for the containing div. This image can be added to the containing div as a background image and repeated down the y axis.

The floating div's then sit over the top of this repeated image, and the colours will extend to the bottom of the page, no matter which column is longer.
Re designed Web site
21 February 2008 Uncategorised
Bubble image
Took time out to redesign my Website, purely with CSS.
Changing title tag dynamically
17 February 2008 Tips
Bubble image
I needed to change the title tag on the fly. The idea being that when the user clicks onto a date on the calendar control for example to pull all the posts relevant for that date, the page title above the address bar in the browser would reflect this and would help in search engine optimization. Search engines rank pages with relevant titles higher than those without relevant titles. By giving this information you are helping the search engine understand your Web page through your page title. Search engines will quickly overlook a Web page with an unrelated page title. The solution for ASP.NET 2.0 is to use Page.Title under the Page_Load event in the code behind.

Page.Title = "post " + Request.QueryString("EventDate")

http://www.velocityreviews.com/forums
Message could not be sent
14 February 2008 Tips
Bubble image

'The message could not be sent to the SMTP server.
The transport error code was 0x80040217.
The server response was not available.'


This means that username and password are incorrect.

 Mail.To = "YourName@DomainName.com"
 Mail.From = txtName.Text

 Mail.BodyFormat = MailFormat.Text
 Mail.Priority = MailPriority.Normal
 Mail.Subject = "Your Reference"

Mail.Body = "From: " + txtName.Text + vbNewLine +
"Email: " + txtEmail.Text + vbNewLine +
"Subject: " + txtSubject.Text + vbNewLine +
"Message: " + txtMessage.Text

Mail.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1")

Mail.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendusername", "YourName@DomainName.com")

Mail.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendpassword",
"Password")

 SmtpMail.SmtpServer = "mail.DomainName.com"
 SmtpMail.Send(Mail)

Note that System.Web.Mail is obsolete and
the alternative is System.Net.Mail

Convert System.Drawing.Color to RGB
04 February 2008 Tips
Bubble image
Use the Color.FromName method:
Drawing.Color.FromName("#f2f2f2")

http://weblogs.asp.net
The constraint cannot be enabled
02 February 2008 Tips
Bubble image
'The constraint cannot be enabled as not all the values have
corresponding parent values.'


Set the constraint in the DataRelation class to false.

ds.Relations.Add("ParentChild", _
ds.Tables("Parent").Columns ("Name"), _
dsTables("Child").Columns("Name"), False)
Must declare scalar variable
02 February 2008 Tips
Bubble image
To get the value of a QueryString field for code behind use:
    Request.QueryString("Name")

    da.SelectCommand.parameters.Add(parameter, _
    SqlDbType.DataType).value = _
    Request.QueryString("name")