Posts

Showing posts from September, 2015

POC on Grid View with TextBox ,DropDown and Button

POC on Grid View with TextBox ,DropDown and Button  A proof of concept on populating a grid view with data from the database .There is a dropdown which takes the list from the database . The textbox present in the gridview is used to add countries in the list of country in the database .On click of the button event the "grdView_RowCommand" is called and respective operation is performed. ASPX file <%@ Page Title="Home Page" Language="C#" CodeBehind="Default.aspx.cs" Inherits="Indexers2._Default" %> <form id="form1" runat="server">     <asp:GridView ID  = "grdView"                runat  = "server"           CellPadding  = "5"         AutoGenerateColumns="false"         onrowcommand="grdView_RowCommand"         AutoGenerateSelectValue="true"         >         <Columns>         <asp:BoundField HeaderText="Name" 

A Drop Down Inside a Grid View

Drop Down Inside a GridView Thanks :Mudassar Ahmed Khan http://www.aspsnippets.com/Articles/How-to-populate-DropDownList-in-GridView-in-ASPNet.aspx aspx page : <%@ Page Title="Home Page" Language="C#" CodeBehind="Default.aspx.cs" Inherits="Indexers2._Default" %> <form id="form1" runat="server">     <asp:GridView ID  = "grdView"                runat  = "server"           CellPadding  = "5"         AutoGenerateColumns="false"         >         <Columns>         <asp:BoundField HeaderText="Name"  DataField="CONTACTNAME" />         <asp:TemplateField HeaderText="Country">             <ItemTemplate>             <asp:DropDownList ID    =   "drpdwnlst"                               runat =   "server"               >             </asp:DropDownList>               </ItemTemplate>  

Func Delegate

Func Delegate ================================== Its a generic delegate.Is is symbolised by Func<T,TResult> . depending on the type paramemters (T and TResult) can be replaced with the corresponding type arguments Func<Employee,string> specifies that it accepts Employee object and returns string object. Both Func<T,TResult> and lambda expression are similar things and differs only in sysntax. Below is  a code snippet with Func<T,TResult> --------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Indexers2 {     public class Employee     {         public int EmployeeId { get; set; }         public string EmployeeName { get; set; }     }     public partial class _Default : Page     {         List<Employee> employeelst;         protected void Pa

Indexers :

Indexers :  They are similar to properties .For ASP .net Web application , We have the concept of session state and application state variables.To retireve the session state and application state variables we use indexers .Indexers allow instance of classes to be indexed just like arrays. public string this[int id]         {             get             {             }             set             {             }         } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; using System.Runtime.Remoting.Messaging; namespace ManualResetEvent_ {     //Company class and Employee classs     class Employee     {         public int EmployeeId { get; set; }         public string  EmployeeName { get; set; }         public int EmployeeSalary { get; set; }     }     //This will contain list of employees     class Company     {         private List<Employee> listEmployee;         public Company()

C# Understanding the TASK class

C# Understanding the TASK class . ======================================================= The Task Object typically executes asynchronously on a Thread Pool thread rather than synchronously on the main Thread.IsCanceled,IsCompleted,IsFaulted,Status property are being used to determine the state of a TASK.Most Commonly Lambda expression is used to specify the work that task is to perform. Task instances may be created in a variety of ways. The most common approach, which is available starting with the .NET Framework 4.5, is to call the static Run method. The Run method provides a simple way to start a task using default values and without requiring additional parameters.  TaskFactory.StartNew --> Is a method to start a task in .NET 4  Task.Run()         -->  Is a method to start a task in .NET 4.5     using System; using Syste m.Collectio ns.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; namespace ManualResetEvent_ {    

A simple Event Handling with Delegate Example

  A simple Event Handling Example using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; using System.Runtime.Remoting.Messaging; namespace ManualResetEvent_ {     // A delegate definition for handling the event . They are like binders linking the event and the handler     public delegate void transactionhandler (object sender, transactionArgs e);     public class transactionArgs : EventArgs     {         public int Transactionamt {get;set;}         public string Transactiontype {get;set;}         public transactionArgs(int amt,string type)         {             Transactionamt=amt;             Transactiontype=type;         }             }     // Publisher of the eevent contains definition of the event of type delegate     public class Account     {         public event transactionhandler transactionMadeEvent; //Creating an Event of type the handler         public int BalanceAmt;         public Acc

OOPs Concepts

What is Abstract class? -------------------------------------------------------------- The abstract keyword enables you to create classes and class members solely for the purpose of inheritance—to define features of derived, non-abstract classes A Sealed class -------------------------------------------------------------- It  cannot be used as an abstract class as it cannot be used as a base class .A class member,method field,property or event on a derived class that is overriding a virtual member of the base class can declare that member as sealed class.This will prevent that method from being overriden in further derivation. This can be accomblished bu putting  the sealed Keyword before the overridde keyword in the class member declaration. Polymorphism : -------------------------------------------------------------- C# recognises the method by its parameters and not only by its name.The return type of a method is never the part of the method signature if the names of the

Can a derived class reference contain base class object.

1)Can a derived class reference contain base class object. using System; public class Base         {         public Base()         {         Console.WriteLine("I am from the Base Class Constructor");         }         public void  Invert()         {         Console.WriteLine("I am an invert function and I belong to Base");         }         } public class Derived:Base         {         public Derived()         {         Console.WriteLine("I am from the derived class constructor");         }         public new void Invert()         {         Console.WriteLine("I am purely from the derived class");         }         public void BaseInvert()         {         Console.WriteLine("I am  from the Derived class by I will implement the base class");         base.Invert();         }         } class Program         {         public static void Main()         {         Derived d =new Derived();         d.BaseInvert();         d.Invert();     

C# Memory Model

C# Memory Model ========================================== check this blog for more details : igoro.com. Volatile Fields : - A read of a volatile field has acquire semantics which means it can't be reordered with subsequent operations            - A write of a volatile field means that it cant be reordered with prior operations. Atomicity : Thread Communication Pattern: The purpose of a of a memory model is Thread Communication .Communications such as when one thread writes something in memory and another thread reads from the memory , the memory model dictates the values the reading thread might see.Locking is one way to ensure that thread don't land up reading dirty content. Lock -- When a locked block of code executes its guaranteed to see all writes  from blocks that precede the block in the sequential order of the lock. Also it is guaranted to see any of the writes from the block that follows it in sequential order of the lock. Publication via Threading API: ==

Executing a CallBack Method , When a Asynchronous call Completed.

Executing  a CallBack Method , When  a Asynchronous call Completed. If the thread that initiates the asynchronous call does not need to be the thread that processes the results, you can execute a callback method when the call completes. The callback method is executed on a ThreadPool thread. To use a callback method, you must pass BeginInvoke an AsyncCallback delegate that represents the callback method. You can also pass an object that contains information to be used by the callback method. In the callback method, you can cast the IAsyncResult, which is the only parameter of the callback method, to an AsyncResult object. You can then use the AsyncResult.AsyncDelegate property to get the delegate that was used to initiate the call so that you can call EndInvoke. Delegate's do this asynchronous call invocation using delegate's BeginInvoke method. First we have to define a delegate with the same signature as the method we want to call. The common language runtime automatica