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