Convert Array of Objects to Data Table
Normally in a web application, the Presentation Layer retrieves an Array/Collection of business objects as the data source to bind to GridView control. However sometimes we do need a DataTable to return. In such cases we need convert an Array/Collection of object to a DataTable.Now let's look into te code.[C#]public DataTable ConvertArrayToTable(Array myList){DataTable dt = new DataTable();if (myList.Length > 0){PropertyInfo[] propInfos = myList.GetValue(0).GetType().GetProperties();foreach (
Import Data From MS Excel to DataSet without using COM Objects
In my last blog I demonstrated how to export data from a DataSet/DataTable to MS Excel file. In this blog I will show you the process reversed - import data from excel to a Dataset without using the COM objects.Now let's start with an code example.Code ExamplePublic Class DataImporterPublic Shared Function ImportExcelToDataSet(ByVal excelFullFileName As String, ByVal targetTable As String) As DataSetDim oledbConnection As OleDbConnection = GetOledbConnection(excelFullFileName)Dim commandText As
Export a DataSet to Microsoft Excel without using the COM objects
It is a routine job to export data from MS SQL Server database to MS Excel, or import data from MS Excel to MS SQL Server database. There are lot of solutions based on MS Excel COM object, which make youe application depends on MS Excel, and you must install MS Excel application on you web application server. This kind of solutions are discouraged for the following reasons.For security reason, your customer maybe would not like to install Excel application on the web application server.The Excel
Integrating/Using NUnit Test Framework with Visual Studio 2010 for ASP.NET MVC Application
ASP.NET MVC 2The Model-View-Controller (MVC) pattern is an architectural design principle that separates the components of a Web application. This separation gives you more control over the individual parts of the application, which lets you more easily develop, modify, and test them.ASP.NET MVC is part of the ASP.NET framework. Developing an ASP.NET MVC application is an alternative to developing ASP.NET Web Forms pages; it does not replace the Web Forms model.If you have installed Visual Studi
Introduce to Data Storage Objects in ASP.NET
Learn about the five powerful ASP.NET storage mechanisms, and how to quickly identify which to use for a given situation.IntroductionIn this brief tutorial, we'll look at five different ASP.NET objects we can use to store data. Two of these, the Application and Session objects, should be pretty familiar to anyone coming from ASP. The other three, Context, Cache and ViewState are brand new to ASP.NET. Each object is ideal under certain conditions, varying only in scope (that is the length of time
Query to Check SP/Table/Trigger Exists in Database or not
We often need create/update Stored Procedure,Tables or Triggers in database via SQL scripts. It is a best practice to check if these objects exist in the database before create/update them.Let's look at several examples1. Checking whether procedure exist in the NORTHWIND database with name 'CustOrdersDetail' Approach -1:use NORTHWINDif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CustOrdersDetail]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)print 'CustOrdersDetail Exists i
HTML Layout Guidelines for ASP.NET Web Page Globalization
The best practice for HTML layout is to ensure that localizers need to translate only strings, because the user interface sizes all controls to fit the text that the strings contain. This is a benefit because the step of manually resizing controls is removed from the localization process, thereby removing the errors and bugs that can result. However, the layout of the controls changes depending on string lengths, so localized Web sites need to be carefully tested.The following list provides reco
How to: Use Resources to Set Property Values in Web Server Controls
In an ASP.NET page, you can use the following methods to read values from resource files:Implicit localization ASP.NET fills property values from a local resource file based on matching keys to properties. By using a tool in Visual Web Developer, you can automatically mark all of the controls on a page for implicit localization.Explicit localization Create an expression that reads a specific resource from a local or global resource file. You should create expressions for every control proper
How to: Retrieve Resource Values Programmatically
You can use declarative syntax to set the values of ASP.NET server control properties to a resource value. Alternatively, you can retrieve resource values programmatically. You might do this if the resource value is not known at design time or if you want to set the resource value based on a run-time condition.You can get resource values from both local and global resource files that use methods that return an object that you can cast to the appropriate type. Because ASP.NET compiles global reso
ASP.NET Web Page Resources Overview
If you create Web pages that will be read by speakers of different languages, you must provide a way for readers to view the page in their own language. One approach is to re-create the page in each language. However, that approach can be labor intensive, error prone, and difficult to maintain as you change the original page.ASP.NET enables you to create a page that can obtain content and other data based on the preferred language setting for the browser or based on the user's explicit choice of
How to: Select an Encoding for ASP.NET Web Page Globalization
Internally, the code behind ASP.NET Web pages handles all string data as Unicode. You can set how the page encodes its response, which sets the CharSet attribute on the Content-Type part of the HTTP header. This enables browsers to determine the encoding without a meta tag or having to deduce the correct encoding from the content. You can also set how the page interprets information that is sent in a request.Finally, you can set how ASP.NET interprets the content of the page itself — in other w
How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization
Globalization is the process of designing and developing applications that function for multiple cultures. Localization is the process of customizing your application for a given culture and locale.In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page
Infragistics WebCombo Javascript API Demonstration
In this blog I will demonstrate how to interact with WebCombo client side API using Javascript. Now Let's begin with an example.As shown above figure, there are several WebCombos on the page. When the right-hand checkbox is checked, the WebCombo is enabled anf get focus; otherwise,the WebCombo is disabled and lost focus.1. Retrieve WebCombo Object ReferenceTo interact with the client side WebCombo object, we need a way to get a reference to it. We can retrieve a WebCombo client side object refer
Sort a WebCombo Column Programly
Infragistics WebCombo control make it very easy to sort a cloumn with few lines of code. There is no need that the source data is ordered.Let see an example.As shown in above figure, the service WebCombo is not sorting and the rows are unordered.To sort a WebCombo column, we need to set the SortIndicator property of a Column object of the WebCombo control.Public Shared Sub BindWebCombo(ByRef control As WebCombo, ByRef dataSource As IBindingList)With control' data bingding.DataSource = dataSource
Select a matching row of WebCombo control based on DataValue
Considering the following scenario:The user selected an item in a WebCombo control then do a "save" action, when he re-enter this page, we want the Webcombo control select the value matching the data from the database. Let's look at an example as below.Supposed that the "Service" WebCombo has a DataTextField named "Code" and a DataValueField named "ID". Now we want to select a row by matching the DataValue of the control. Normally the code looks like below
Infragistics WebCombo Data Binding
Infragistics ASP.NET web controls are very usful and populate by web page developers. In this series articles I will share my expierences on Infragistics controls usage with you. The topic of this blog is how to bind WebCombo to a data source.You can bind WebCombo to an ArrayList, Object Collection or DataTable, and it supports binding to single column and multiple columns. Now let's look an example.1. Bind To a DataTable With Single Column VisibleThe ASP.NET page looks like below:All the WebCom
Assign Shortcut key for ASP.Net Page Using Javascript
Shortcut key gives end user more friendly interactions and performance. In this blog I will demonstrate how to implement a shortcut key access for ASP.NET page controls, using Javascript.Detecting keystrokesThe key point here is to capture window event of web browser. As we all know, browser vendors start experimenting when there's no official standard, and these experiments, though occasionally useful, also cause incompatibilities. The key events are no exception: there are currently two proper
Custom Paging in ASP.NET 2.0 with SQL Server 2005
In web application it is a routine to paging data retrieved from the database. And in ASP.NET 2.0 it is very simple to paging data by enable the "AllowPaging" property of GridView. This solution works well when the database data amount is not very large. However, if you want to page through thousands, tens of thousands, or hundreds of thousandsof records the default paging model is not viable. 1. Paging Data with SQL Server 200create procedure [dbo].[P_GetPagedOrders2000](@startIndex i
C# DateTime.ToString() Usage Demonstration
Formatting of Date and Time is an routine in application devlopment. In this blog I would show you how to format a DateTime value using DataTime.ToString() method in a specific culture.1. Format PatternThe following table lists the standard DateTime format patterns associated with DateTimeFormatInfo properties. For more information, see Standard Date and Time Format Strings.The following table lists the custom DateTime format patterns and their behavior. For more information, see Custom Date and
Building Cascading DropDownList in ASP.Net Using jQuery and JSON
Cascading DropDownList is a technique where we populate a child DropDownList based on the parent DropDownList selection. It is often used in web applications. In this blog I will show you how to implement a cascading dropdownlist using jQuery and Json in ASP.Net.Let's begin with a real example.As shown in pictures above, when we select a Building in Home Building DropDownList, it will populate the HomeRoom DropDownList based on the HomeBuilding selected.Now let's take a look at the key points.1.