Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Downloads | Blogs | E-Books | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » AJAX » AJAX DataGrid: An ASP.NET User Control

AJAX DataGrid: An ASP.NET User Control

This DataGrid is a Client Side Control. It is created by JavaScript and uses Ajax.net technology.

Technologies: .NET 1.0/1.1, ADO.NET, ASP.NET 1.0,Visual C# .NET
Total downloads : 4408
Total page views :  85246
Rating :
 4.2/5
This article has been rated :  10 times
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
src.zip
 
Become a Sponsor


Related EbooksTop Videos

Introduction:

 

This DataGrid is a Client Side Control. It is created by JavaScript and uses Ajax.net technology to communicate with ASP.NET code behind, from there, using ADO.NET to access the database and update the database with dataset.

 

This control has all the features that a DataGrid should have and all the functions work automatically without writing any code after you setup the connection string and table names.

 

The datagrid support:

 

  1. Pages.
  2. Sort.
  3. Master - Detail (the detail part also support page and sort)
  4. Customized row color based on the Column condition.
  5. Edit.
  6. Scroll bar without head scroll when no page supported.
  7. Support controls (Image, TextBox, Hyper link, DropdownBox, CheckBox).
  8. Auto split head name.
  9. Automatic validate textbox for Decimal, email and number.

The datagrid can be switched between different modes by right click on the screen to open a popup screen:

 

 

  

The Datagrid with Page, Master-Detail and Edit function

 

 

 

The Datagrid with custom controls and scrollbar with static head

 

Performance:

 

The grid is created by javascript on demand and JavaScript is not a compiled language. It is slower than render xtml code directly to the page. If the datagrid contains more than 200 records it is better to use the page mode. Otherwise the performance will slowdown a lot.

 

The CSS (Cascading Style Sheets) is used to configure the look of the control, so the user can make the change very easily.

 

Usage:

 

The user control includes five parts:

 

  1. User control .ascx file.
  2. JavaScript file.
  3. Database access file.
  4. CSS file.
  5. AJAX.NET dll.

First, Add reference to ajax.dll.

 

Copy the UserControl directory to your project and add the user control to your ASP.Net page: (see the project in the source code)

<%@ Register TagPrefix="WebDataGridDemo" TagName="WebDataGrid" Src= "UserControl/WebDataGridUserControl.ascx"%>

<WEBDATAGRIDDEMO:WEBDATAGRID id="wdg1" runat="server"> </WEBDATAGRIDDEMO:WEBDATAGRID> 

In the Web.config file, setup the connection string. Add reference to Ajax.net dll:

 

<appSettings>

           <add key="ConnectionString" value="Data Source=(local);Initial Catalog=Northwind;User Id=sa;Password=xxx;" />

</appSettings>

 

<httpHandlers>

      <add verb="POST,GET" path="

          type="Ajax.PageHandlerFactory, Ajax " />

</httpHandlers>

 

In the DynamicDataGrid.js file, most parameters have default values that you can overwrite some of them in your webform that use the control.

 

private void Page_Load(object sender, System.EventArgs e)

{

if(!Page.IsPostBack)

{       

WebDataGridUserControl.MainTableName="suppliers";

           WebDataGridUserControl.DetailTableName = "products";

 

           // optional these values will overwrite default properties

           WebDataGridUserControl.Height =300;

           WebDataGridUserControl.Width = 780;

           WebDataGridUserControl.Editable = 1;

           WebDataGridUserControl.PageSize = 4;

}

}

 

Configuration:

 

Also you can modify some parameters in the WebDataGridUserControl.ascx.cs file:

 

If you don't use page mode, you may need to change the array ResetIfNoEditable and columnWidth to adjust the grid head column size and columns size.

 

[Ajax.AjaxMethod]

public ArrayList InitializeInfo()

{

...

           // int pageable=1; masterDetail =1;editable = 1;pageSize=10; height=300

           string [] FunctionProperty = {"1", "1", gEdit, gPageSize, gridHeight, gridWidth};

           // ={} no control available; 0 label, 1 image, 2 href link 3 textbox 4 checkbox 5 dropdown

           string [] ColumnControlType = {"0","2","3","3","0","3","4"};

           // indicate which column 3,4,5,7 is editable

           string [] ColumnEditable =   {"0","0","1","1","1","0","1"};

 

           // following properties only for no page supported

           // this rearrange size of edit button to column 3, 4, 5 with added size 10,10,10

           string [] ResetIfNoEditable = {"0","0","10","10","10", "0"};

 

           string [] CustomizedHeadZize={"68","140","120","120","120", "0"};

           // Column size needed when no page support is set; you should set one column to "0"

           string [] columnWidth ={"68","140","120","120","120","0"};

           ...

           return al;

}

 

[Ajax.AjaxMethod]

public ArrayList GetHeadArray()

{

...

           // this array should match with the edit fields column3= Decimal, column4=Email,column5=Number

           string [] ValidateType =   {"","","Decimal","Email","Number"};

           // assign ColumnDisplayName = {}; if don't use customized display name

           string [] ColumnDisplayName = {};

...

}

 

Thanks Michael Schwarz who created a ajax.net that build the bridge between JavaScript and the .Net.


Login to add your contents and source code to this article
 [Top] Rate this article
 About the author
 
Jibin Pan
Jibin Pan is vc++, c programmer at Interactive Edge Corp. Xtend Communications Corp. MoneyLine Corp in new york city since 1994 and has Master degree at computer science.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
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.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Microsoft Visual Studio 2010 offers more to developers than any other Visual Studio release. Work more productively and collaboratively-with greater control over your work at every step. The Beta 2 can give you a head start on achieving efficiency.
 
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
src.zip
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
Become a Sponsor
 Comments
Databind method needed by wisey On May 22, 2006

Is there a way to implement your datagrid with using results a query intead of the database table structure. For example binding the two tables with dataset instead of giving the table names?

Thanks in advance

Reply | Email | Delete | Modify | 
Good! by Tran Tien Dzung On June 5, 2006
Good!
Reply | Email | Delete | Modify | 
Re: Good!Gridview by chandra On May 8, 2009
hi

You are given a given code is 1.1 but i need dotnet 2.0 version plz any body help ..this is very urgent..

thanks
mohan
Reply | Email | Delete | Modify | 
Turn ASP.NET controls into AJAX enabled controls. by Eric On July 9, 2006

89-89

Reply | Email | Delete | Modify | 
Thanks by Michael On January 4, 2008
Thanks u is good sample
Reply | Email | Delete | Modify | 
Thanks by Michael On January 4, 2008
Thanks u is good sample
Reply | Email | Delete | Modify | 
Thanks by Michael On January 4, 2008
Thanks u is good sample
Reply | Email | Delete | Modify | 
Re: Thanks by ajeet On March 24, 2008
Please send me code , as i am  not able to download,Please help
Reply | Email | Delete | Modify | 
Can we update this code? by murali On September 1, 2008
How can we install and customize it?
Reply | Email | Delete | Modify | 
Re: Can we update this code? by chandra On May 8, 2009
Can you update the code dotnet 2.0 version.

plz this is very urgent
Reply | Email | Delete | Modify | 
Thakns by ramesh On November 25, 2008
its great job..its helping me to a lot....
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 1999 - 2009  Mindcracker LLC. All Rights Reserved