This keyword was introduced in .NET 4.0. It provides the access to DLR
(Dynamic Language Runtime) using this specific keyword. It intimates the
compiler to perform dynamic calling which is resolved at the run time. It uses
namespace. It simplifies tasks with interoperability providing access to COM
API's and Dynamic API's.
Now, we will not spend more time in studying theory, It time to go and do a
simple practical demo.
So, Firstly I have created simple database which looks like this:
Let's create new project with unique name:
The Complete Code of Default.aspx file looks like this:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Dynamic_Keyword.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head
id="Head1"
runat="server">
<title></title>
</head>
<body>
<form
id="form1"
runat="server">
<div>
<center>
<asp:GridView
ID="GridView1"
runat="server"
BorderColor="#CC9966"
BorderStyle="None"
BorderWidth="1px"
CellPadding="4">
<FooterStyle
BackColor="#FFFFCC"
ForeColor="#330099"
HorizontalAlign="Center"
/>
<RowStyle
BackColor="White"
/>
<HeaderStyle
BackColor="#990000"
Font-Bold="True"
ForeColor="#FFFFCC"
/>
<PagerStyle
BackColor="#FFFFCC"
ForeColor="#330099"
/>
<SelectedRowStyle
BackColor="#FFCC66"
Font-Bold="True"
ForeColor="#663399
/>
<SortedAscendingCellStyle
BackColor="#FEFCEB"
/>
</asp:GridView>
</center>
<SortedAscendingHeaderStyle
BackColor="#AF0101"
/>
<SortedDescendingCellStyle
BackColor="#F6F0C0"
/>
<SortedDescendingHeaderStyle
<br
/> <br
/>
<center><asp:Button
ID="Button1"
runat="server"
Text="Click Here"
onclick="Button1_Click"
/>
</center>
</div>
</form>
</body>
</html>



Join the conversation! Your thoughts help the community grow.