SIGN UP MEMBER LOGIN:    
ARTICLE

DynamicField class used by GridView to display data fields that use .NET Dynamic Data features.

Posted by Shinuraj Articles | ASP.NET Programming February 18, 2011
Here is one sample code that explains how to use the DynamicField class inside a Gridview
Reader Level:

Here is one sample code that explains how to use the DynamicField class inside a Gridview

Follow the steps to add dynamic behavior to a GridView

  1. In Visual Studio 2010 open the Web site.
  2. Add one EntityDataSource control or the LinqDataSource control.
  3. Add a GridView control and DynamicDataManager control to the page.
  4. Set the ControlID property of the DataControlReference element in the DynamicDataManager control to the ID of the GridView control.
  5. Set the DataSourceID property of the GridView control to the ID of the EntityDataSource control or the LinqDataSource control.
  6. For each column in the GridView control add a DynamicField control as shown in the ASPX code below

And set the DataField property of the DynamicField control to the name of the data column or row that you want to bind to.

ASPX:

<asp:GridView     ID="GridView1"

runat="server" DataSourceID="GridDataSource"

EnablePersistedSelection="True" AutoGenerateColumns="False" GridLines="None" AllowPaging="True" AllowSorting="True"  >

    <Columns>
     <asp:DynamicField DataField="ProductID" HeaderText="Product ID" />
     <asp:DynamicField DataField="ProductName" HeaderText="Product Name" />
     <asp:DynamicField DataField="Description" HeaderText="Description" />
     <asp:DynamicField DataField="ModifiedDate" HeaderText="Modified Date" />
    </Columns>

    <PagerTemplate>
        <asp:GridViewPager runat="server" />
    </PagerTemplate>
    <EmptyDataTemplate>
        There are currently no items in this table.
    </EmptyDataTemplate>   
</asp:GridView>

Shinu

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Gauge for SharePoint
Become a Sponsor