ASP.NET

Format String with String.Format and C#

January 3rd, 2009 | Posted in ASP.NET
4

<%# String.Format("{0:#####-####}", Convert.ToInt32(Eval("ZipCode"))) %> It is necessary to convert the ZipCode field to an integer in this instance because the Format class expects an integer to properly format a number, otherwise it will only return the string or value that you passed to the Format class. I am using this in conjunction with the MaskedEditExtender, ...

Return Single Value with ExecuteScalar, Stored Procedures and C#

December 3rd, 2008 | Posted in ASP.NET, SQL Server
3

A common query is to return a single value from a SQL query such as an aggregate to get the total number of rows in a table. I will show you how to do just that with SQL Server Stored Procedures and C#. Preparation You will need some table data to query against. I am ...

Add a Count Column to Your Gridview, Datalist or Repeater

November 30th, 2008 | Posted in ASP.NET
0

Found this great article on how to add a counter column to your data rich controls. http://www.lazyasscoder.com/AspNet/Article.aspx?id=55&title=How+To%3A+Add+a+row+count+column+to+a+GridView%2C+DataList+or+Repeater The above article is specific to a GridView. Here is an example with a Repeater control. <asp:Repeater ID="repeater" runat="server"> <ItemTemplate> <%# Container.ItemIndex + 1 %> <%# Eval("field_name") %>'> </ItemTemplate> </asp:Repeater>...

Add Items Dynamically to .NET Arrays with C#

November 30th, 2008 | Posted in ASP.NET
0

If you are in a situation where you need to add an item to an array you will need to use one of the collection classes such as the Arraylist. New values cannot be added to an array that has set values. String Array Example string[] list = new string[] { "one", "two", "three" }; ...

Dreamweaver and Disappearing ASP.NET Directives

November 28th, 2008 | Posted in ASP.NET, Software
0

If you are working with Dreamweaver templates and your ASP.NET directives keep disappearing try the following. Place <%–’comment–%> on the second line after your page declaration on your content pages. You can leave your template as is. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="default" %> <%--'comment--%> You do not need to set the <!– TemplateInfo codeOutsideHTMLIsLocked=”false” ...

Visual Studio.NET Error List and Task List

November 27th, 2008 | Posted in ASP.NET, Programming
0

Here is a great article that explains the Error and Task List within Visual Studio. The Error List shows any errors and warnings within your project and the Task List helps you track your progress and mark items as completed just as you would with an external todo list application. Read more at http://en.csharp-online.net/Visual_Studio_Web_Applications%E2%80%94Error_List_and_Task_List...

My Essential Developer's Toolbox – Part I

November 23rd, 2008 | Posted in ASP.NET, MySQL, PHP, Programming, SQL Server, Software
2

This is a multi-part post that lists all of the tools that I use on a regular basis as a web developer. The list is Microsoft Windows centric but I will point out the applications that are cross-platform (as best as I can). IDEs (Integrated Development Environment)* Microsoft ASP.NET Both of the IDEs below are ...

PHP implode() Function with C#

November 23rd, 2008 | Posted in ASP.NET
0

The following snippet will join values in an array with a specified separator. string[] items = new string[] { "one", "two", "three" }; string.Join(", ", items);...

Missing ASP.NET Tab in inetmgr

November 23rd, 2008 | Posted in ASP.NET, IIS
0

If your ASP.NET tab has disappeared (mine was caused by installing ISAPI_Rewrite) then the following MSDN blog article has a tool you can use to fix it. http://blogs.msdn.com/tom/archive/2008/04/17/asp-net-tab-missing.aspx...

Find a Nested Web Control within a Web Control with C#

November 20th, 2008 | Posted in ASP.NET
0

I was having issues accessing a web control directly within a user control and used the following to access the web control within a LoginView in the User Control. The same syntax below can be used if you are looking for a nested control within a control. System.Web.UI.WebControls.Literal name_literal = (System.Web.UI.WebControls.Literal)this.LoginView1.FindControl("name"); name_literal.Text = "Text goes ...