Monthly Archives: February 2011

Object reference not set to an instance of an object – when using FindControl with Listview web control

When you the error as below.       Look at the picture below.     I have Panel declared and compiled successfully.   Panel p1 = (Panel)ListView1.Items[i].FindControl(“Panel1”);   At the same time I have Panel1 declared in Listview as … Continue reading

Posted in .Net | Tagged | 3 Comments

How to execute an sql script file using C#

1. Add the following reference.     2. Add the using section.   using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Common;   3. The hris_db1.sql is the sql script file.   string strConnData = “Data Source=.;Initial Catalog=maser;Integrated Security=True”; SqlConnection connData = new SqlConnection(strConnData); FileInfo … Continue reading

Posted in .Net | Tagged | Leave a comment

Creating TreeView in ASP.NET

1. Create a Web Project.   2. Follow the video below.     Code in page load event: protected void Page_Load(object sender, EventArgs e) {   //Add child node value   TreeNode tnc = new TreeNode(“Manager”);   //Add parent value … Continue reading

Posted in .Net | Tagged | Leave a comment

Disable Textbox in EditItemTemplate in ListView – ASP.NET

1. Modify the sample you have created in “Loop / iterate through ListView items” or download the sample from skydrive.   2. Enable Edit in LisView.       3. Add the following code in Databound event.   protected void … Continue reading

Posted in .Net | Tagged | Leave a comment

The Future of C# and Visual Basic by Anders Hejlsberg

The best session for me in PDC 10 live. http://player.microsoftpdc.com/Session/1b127a7d-300e-4385-af8e-ac747fee677a

Posted in .Net | Tagged | Leave a comment

Applying Cascading Style Sheet (CSS) to ListView – ASP.NET (code and video)

1. Modify the sample you have created in “Loop / iterate through ListView items” or download the sample from skydrive.   2. Follow the video.      3. Run the project.   Download the complete code from http://skydrive.live.com. The sample … Continue reading

Posted in .Net | Tagged | Leave a comment

Change cell color in ListView – ASP.NET

1. Modify the sample you have created in “Loop / iterate through ListView items” or download the sample from skydrive.   2. Add a Panel control to wrap the label in <ItemTemplate> and <AlternatingItemTemplate> section, for example you want the … Continue reading

Posted in .Net | Tagged | 1 Comment

Loop / iterate through ListView items – ASP.NET (Code sample and Video)

1. Create a Web Project.   2. Create a class to keep the contents. Here I created Employee class.   using System; using System.Collections.Generic; using System.Linq; using System.Web;   namespace WebAppListViewColor {   public class Employees   {     public … Continue reading

Posted in .Net | Tagged | 8 Comments

First SQL Server reporting services (SSRS) sample – Tabular report

1. Download the sample here: http://msftdbprodsamples.codeplex.com/releases/view/55926   SSRS can be installed trough SQL Server Standard or Enterprise editions. For SQL Server 2008 Express download the Database with Advanced Services here: http://www.microsoft.com/express/Database/InstallOptions.aspx   2. Watch the Getting Started with Reporting Services … Continue reading

Posted in .Net | Tagged | Leave a comment

Expression Trees C# – The complete sample

Expression Trees C# – The complete sample In theory Expression Trees data type will use memory efficiently. I am still finding a practical use of this. It is fun anyway. Create a C# console project and paste the below code … Continue reading

Posted in .Net | Tagged | Leave a comment