ASP.NET GridView: Sort data using column headers

How to sort data in ASP.NET GridView using column headers GridView is a powerful data grid control which allows us to display the values of a data source in a table format where each column represents a field and each row represents a record. The GridView control lets you select, sort, or edit these data... » read more

Disable a DropDownList item in Asp.Net using C#

In this article, we will learn how to disable an item (option) using C#. After disabling it, the user will not be able to select the DropDownList. How to Disable a DropDownList first item in Asp.Net using C# Let’s create a simple table ‘customers’ as shown below: CustomerId (INT), CustomerName (NVARCHAR 50) CustomerEmail (NVARCHAR 50)... » read more

A simple ASP.NET login system using C#

In this article, we will learn how to create a simple user authentication system in Asp.Net using C#. The user’s credentials will be saved in the database and will be retrieved to verify the login information. Create a login module using ASP.NET In this tutorial, The login system consists of two pages. Login Page: Login.aspx... » read more

ASP.NET GridView RowUpdating event using C#

In this article, we will learn how to use the RowUpdating event of GridView in Asp.Net using C# with an example. This example takes advantage of GridView control and perform edit and update operations on data and save the changed data in the database. RowUpdating event in the GridView in Asp.Net using C# Let’s get... » read more

LINQ Aggregation methods in C#

Below are the most used aggregation functions in the Linq class with examples. First, add the namespaces as shown below: using System.Collections.Generic; using System.Linq; Now, create a list of type integer and assign a few variables to it. List<int> list = new List<int>() { 1, 2, 3, 4, 5 }; LINQ Sum Function It returns... » read more

C# List Examples

A list is a generic collection of items that can be accessed by index. You can access, search, sort, or manipulate the list items just like you can do with an Array. What is a list in C# The List is a class in the System.Collections.Generic namespace. It is a generic class that any type... » read more

How to start, stop, and restart Windows Services using C#

Windows Services are a core part of the Windows Operating System which is responsible for creating and managing the long-running processes. In this article, we will learn how to start, stop, and restart a windows service using C# programming language. Starting a Windows Service using C# This method below will start the windows service “aspnet_state”... » read more

C# String Format for DateTime Overview

In this tutorial, we are going to use the method String.Format to format string for DateTime DataType. Format a String for DateTime using C# Example: DateTime dateTime = DateTime.Now; String date; date = String.Format("Date & Time Format: {0}", dateTime); Console.WriteLine(date); date = String.Format("Date Only Format: {0:D}", dateTime); Console.WriteLine(date); date = String.Format("Time Only Format: {0:T}", dateTime);... » read more

String.Format in C# for Decimal

In this article, we will learn how to use the String.Format function to format a string into Decimal number format. How to format a Double in C# using String.Format For example, if you have to format a number up to two decimal places, use a pattern that specifies two zeros after point such as 0.00.... » read more

C# FileStream: open, read, write files in C#

In .NET Framework, the System.IO namespace contains classes and functions that are used for file-related functionality, such as creating, reading, writing, updating, or closing a file. In this article, we will look at the FileStream class and its importance in WinForms applications. Using FileStream Class in C# for file operations It is a recommended programming... » read more

Introduction to File attributes in C#

In this article, we will learn about file attributes in C#, how to set or get file attributes, and the FileAttributes Enum. FileAttributes Enum The file Attributes is an Enum that contains attributes fields that can be set or get when dealing with files or directories. Here are the lists of the fields of the FileAttributes... » read more

How to get time information of a file in C#

In this article, you will learn how to get time-related information of a file. There are two different methods to achieve this. You can either use static methods of File class or call methods of FileIno class after initiating it. Get time information of a file in C# using the File Class Let’s say you... » read more

Catch Unhandled Exceptions in WinForms Apps using C#

In this article, we will learn how to handle an unhandled exception being thrown in C#. An exception is an error that occurs at runtime, and an unhandled exception occurs when the application fails to handle the exception being thrown properly. Unhandled Exceptions in C# Applications The UnhandledException Event notifies an app whenever an unhandled... » read more