Posts

Showing posts from June, 2018

Data binding in ASP .NET using AJAX & SQL Database

Image
This post is illustrate the process of data sharing from server to client using AJAX. There are lots of advantages of using AJAX. The Main advantage of using AJAX is we just need to transfer data which is required. For example when HTML page loaded then for each subsequent operation (Excluding the redirect) we don't need to reload page again and again. Let's see how this can be implemented in ASP .NET Webform as well as ASP .NET MVC. Created simple product table, we will be retrieving data from this table only. I am using ADO.NET for database connection. We will use JQuery library to make an ajax call to the server. WebForm In case of WebForm, we will create WebMethod which will be called using AJAX. On Client side above webmethod is called using JQuery AJAX. The result is MVC In case on MVC, we will create Method in controller which will return JsonResult. On Client side in Razor it will be called using JQuery AJAX. The result is

Creating Hierarchical Structure in C#

Image
There are many instances encountered by developer to create hierarchical data structure. For example, Category Hierarchy in E-Commerce. Electronics Mobiles Android Mobiles Samsung Motorola One Plus Windows Mobiles Lumia Laptops Gaming Laptops Dell 4GB RAM 6GB RAM 8GB RAM HP 4GB RAM 6GB RAM 8GB RAM Appliances AC Inverter AC Window AC Almost in all instances this data will come from single table (Assuming data is stored in database). Table structure would be. Category Column Name DataType Description CategoryId bigint PK Name nvarchar(100) Not Null ParentCategoryId bigint default(0) All Category have ParentCategoryId value, which refers to CategoryId of column allowing us to perform self join.  ParentCategoryId=0 informs that the category don't have any parent.i.e topmost category. Now above hierarchy will be stored as follows: