Tag Archives: C#

ReportViewer Error : Operation is not valid due to the current state of the object

I was getting this error in my ASP.NET application when I try to load a report into the report viewer control. To solve this I used the Reset() method of the report viewer control.

oReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote
oReportViewer.Visible = True
oReportViewer.ServerReport.ReportServerUrl = New System.Uri(sReportServiceURL)
oReportViewer.ServerReport.ReportPath = sReportName
oReportViewer.ShowParameterPrompts = False
oReportViewer.ShowDocumentMapButton = False
oReportViewer.DocumentMapWidth = 0
oReportViewer.ShowDocumentMapButton = False
oReportViewer.ShowFindControls = False

Leave a comment

Posted by on September 27, 2012 in Programming


Tags: , , , , , , , , , ,

Malahide Beach

Programming Languages

What do you use for programming? I mainly use VB.Net, I used and enjoyed C#. And as a web developer I used JavaScript. I remember doing some php long time ago. In the university I used Assembly, Fortran, and VB 6.0

But I only speaks two languages

Malahide Beach

Malahide Beach

Leave a comment

Posted by on September 23, 2011 in Photography


Tags: , , , , , , , , , , ,

Using ASP.NET Mobile Forms

I wanted to use the normal ASP.NET Forms stuff in a mobile form.

  • Right click on the web site project and select Add new Item


  • Select Mobile Web Form. enter a name for the form and click on Add button


  • To use a style sheet & a JavaScript file, I added a DeviceSpecific with SupportJavaScript Filter. this is how the HTML code looks like


  • Now I wanted to created some ASP controls. so I added another DeviceSpecific with isHTML32 Filter. this is how the HTML code looks like



  • One last thing, in order to make those DeviceSpecific Filters to work you need to add the required keys in the web.config file. this is how this would look like



Posted by on February 5, 2010 in Programming


Tags: , , , , , , , , , , , , , , ,

GridView: Wrong Fields Order


I was working on a GridView that is binding to a custom class collection to display its properties. the fields in the GridView were ordered depending on the order of the properties in the Class. everything was working fine. until I moved the code to a different development environment.

In the new development environment the order of the GridView fields was not as expected. after spending a lot of time trying to fix that. I installed the .NET 2.0 service pack 2 and that solved the problem!!!!

You can download the .NET 2.0 SP2 from here

Leave a comment

Posted by on January 27, 2010 in Programming


Tags: , , , , , , ,

C#:Using Dictionary as DropDownList Data Source

I have IDictionary Object called ListOptions. To use it as the data source for an ASP.NET DropDownList called objDropDownList:


objDropDownList.DataSource = ListOptions;

objDropDownList.DataTextField = “Value”;

          objDropDownList.DataValueField  = “Key”;





Leave a comment

Posted by on March 31, 2009 in Programming


Tags: , , , , , , , , , , , , , ,

How to sort a collection to be used in DropDown List

I have a collection object (EmployeesCollection) for custom Employee class, In the Employee class there are two properties Name and EmployeeID. I want to sort the EmployeesCollection by Name and use it in a DropDown List (ddEmployees).


DataTable dtEmployees = new DataTable();



          foreach (Employee vEmployee in EmployeesCollection)


                    dtEmployees.Rows.Add(new object[] { vEmployee.Name, vEmployee. EmployeeID  });


          dtEmployees.DefaultView.Sort = “Name”;

          ddEmployees.DataSource = dtEmployees;

          ddEmployees.DataTextField = “Name”;

          ddEmployees.DataValueField = “EmployeeID”;






Leave a comment

Posted by on February 18, 2009 in Programming


Tags: , , , , , , , , , , , ,

Getting the Table Name of a field in a View (SQL2000, C#)

So I have a View that join different tables, I wanted to get the Table name of a Field in the View. So I created a Function [GetTableName] with the following Inputs


         View Name

         Connection String of the View.

         The required Field Name


This is the function


public string GetTableName (string ViewName, string ConnString, string FieldName)


            SqlConnection MyConnection;

            string toReturn = ViewName;


            MyConnection = new SqlConnection(ConnString);



            DataTable MyTable = MyConnection.GetSchema(“Views”);

            foreach (DataRow dRow in MyTable.Rows)


                object[] sqlArray = dRow.ItemArray;

                if (sqlArray.GetValue(2).ToString() == ViewName)


                    DataTable MyVTable = MyConnection.GetSchema(“ViewColumns”);

                    foreach (DataRow dVRow in MyVTable.Rows)


                        object[] sqlVArray = dVRow.ItemArray;

                        if (sqlVArray.GetValue(2).ToString() == ViewName)


                            if (sqlVArray.GetValue(6).ToString() == FieldName)


                                toReturn = sqlVArray[5].ToString();










            return toReturn;





Leave a comment

Posted by on October 10, 2008 in General, Photography


Tags: , , , , , , , , , , , , , ,

Handling an Application Event in another application

I was working on a Console application that read SQL Database connection details from a configuration file then send these details to another application (Let us call it the Update Application) which will go through the records of a table to update them using a For Loop, I wanted to show a status message on the Console screen for each record.


In the Update Application (VB.NET) I defined a Public event to handle the status message


Public Event Message(ByVal sMessage As String)

In the update function I raised this event with the required message

For Each dbRow In DataSet.Tables(“DataTables”).Rows


      RaiseEvent Message(“Start Processing record of ID “  & dbRow (“ID”).ToString())

                    ‘Do the Update Here                          

      RaiseEvent Message(“End Processing record of ID “  & dbRow (“ID”).ToString())




In the Console Application (C#) I defined a handler for the event



  using System;

  using System.IO;

  public delegate void UpdateAppMessageHandler(string myString);


 I defined the required function for the event handler



   internal class Program


        UpdateAppMessageHandler MySEvent = new UpdateAppMessageHandler (ConsolAppMessageHandler);


        static   void  ConsolAppMessageHandler(string sMessage)




Now I need to assign the Update Application event to the event handler in the Console Application


  private static void Main(string[] args)




                UpdateApp MyUpdateApp = null;

                MyUpdateApp = new UpdateApp ();

                MyUpdateApp.Message += ConsolAppMessageHandler; 




Now the Console Screen will show a message for Start/End processing of each record in the Database
Leave a comment

Posted by on September 17, 2008 in General, Photography


Tags: , , , , , , , , , , , ,

Retrieve C# code out of EXE Assembly

I lost some of my applications code coz of PC format, one of these applications is a C# Console Application, I managed to get the exe output of this application but I was not able to retrieve the code files so I used (.NET Reflector) to do this:


1-     Download the .NET Reflector.


2-     Download the Reflector.FileDisassembler.


3-     Extract the .Net Reflector


4-     Extract the Reflecter.FileDisaembler


5-     Copy the Reflector.FileDisassembler.dll to the .Net Relector Folder


6-     Start Relector.EXE


7-     From the View menu select Add-Ins



8-     In the Add-Ins Screen select Add and select Reflector.FileDisassembler.dll then close the Add-Ins screen



9-     From File menu select Open and select the exe file you want to retrieve its code



10- The reflector will load the file Assembly in the Assemblies section



11- Select the required file and from the Tools menu select File Disassembler




12- Click Generate and you will get your code




 Finally I would like to thank Siderite for his help


Posted by on July 31, 2008 in General, Photography


Tags: , , , , , ,

%d bloggers like this: