Thursday, 30 January 2014

Instead of using Cascading Dropdown list in AJAX use LINQ


I've seen many of them are using Ajax "Cascading DropdownList" for selecting countries and states and other all .....
But the far better way is to use LINQ(Language Integrated Query) ....
Today i am going to share with you the linq query for selecting state on selection of Country dropdown....:)

Front end Image:



Developing :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    DataClassesDataContext data = new DataClassesDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            var fetch = from m in data.CountryTabs select new { m.C_ID, m.CountryName };
            DropDownList1.DataTextField = "CountryName";
            DropDownList1.DataValueField = "C_ID";
            DropDownList1.DataSource = fetch;
            DropDownList1.DataBind();
        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
      
        
        var fetch = from m in data.StateTabs where m.Cntry_ID==Convert.ToInt32(DropDownList1.SelectedItem.Value) select new {m.StateName};
        DropDownList2.DataTextField = "StateName";
        DropDownList2.DataValueField = "StateName";
        DropDownList2.DataSource = fetch;
        DropDownList2.DataBind();



    }
}

Instead of using Cascading Dropdown list in AJAX use LINQ


I've seen many of them are using Ajax "Cascading DropdownList" for selecting countries and states and other all .....
But the far better way is to use LINQ(Language Integrated Query) ....
Today i am going to share with you the linq query for selecting state on selection of Country dropdown....:)

Front end Image:


Developing :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    DataClassesDataContext data = new DataClassesDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            var fetch = from m in data.CountryTabs select new { m.C_ID, m.CountryName };
            DropDownList1.DataTextField = "CountryName";
            DropDownList1.DataValueField = "C_ID";
            DropDownList1.DataSource = fetch;
            DropDownList1.DataBind();
        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
      
        
        var fetch = from m in data.StateTabs where m.Cntry_ID==Convert.ToInt32(DropDownList1.SelectedItem.Value) select new {m.StateName};
        DropDownList2.DataTextField = "StateName";
        DropDownList2.DataValueField = "StateName";
        DropDownList2.DataSource = fetch;
        DropDownList2.DataBind();



    }
}

Thursday, 2 January 2014

Understanding C#


Before going towards ASP.NET the use of C# or VB.NET is important.Because as i said that ASP.NET is compiled using VB.NET/C# compiler. That means these are the code behind file, in which the logic would be sustained and the ".aspx" (Active Server Page Extension)is the Source file which contains Desigining part.

Tuesday, 31 December 2013

Chapter-1 What is .NET?


.NET(Networking Enabled Technology)

.NET is a technology that encompass .net framework through which various web-desktop application can be made using languages ASP.NET,VB.NET,etc.
Various versions of .NET FrameWork are :
The Core part of .net framework is

CLR(COMMON LANGUAGE RUNTIME) that manages the execution of .net code.


The Common Language Runtime (CLR) is the virtual machine component of Microsoft's .NET framework and is responsible for managing the execution of .NET programs. In a process known as just-in-time compilation, the compiled code is converted into machine instructions that, in turn, are executed by the computer's CPU.[1] The CLR provides additional services including memory management, type safety and exception handling. All programs written for the .NET framework, regardless of programming language, are executed by the CLR. It provides exception handling, garbage collection and thread management. CLR is common to all versions of the .NET framework.
Flag Counter

How To Pass An Array As A Parameter While Calling an ASP.NET Web API C#

Please visit my C# Corner Blog for this, where I have provided better efforts to make this concept more understandable - www.c-sharpcorner....