|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionRecently, I came across an article by Dave Massey, Fun with Tables using DHTML behaviors, on MSDN. The article was quite interesting and had provided dynamic effects such as drag and drop columns of table, sorting of data on any column using DHTML behaviors. I felt why not apply these behaviors in applications being developed using ASP.NET? As you are aware, ASP.NET BackgroundIn my sample application, I am showing employee list from NorthWind database and binding it to Using the code<asp:repeater id="employeeList" Runat="server">
<HeaderTemplate>
<table id="MyTable"
style="behavior:url(dragdrop.htc) url(tablehl.htc) url(sort.htc);">
<thead bgcolor="#000000" style="FONT-SIZE: 12px; COLOR: white">
<tr>
<td width=200>Employee ID</td>
<td width=200>First Name</td>
<td width=200>Last Name</td>
</tr></thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="#ccffff" style="FONT-SIZE: 12px; COLOR: red">
<td><%# DataBinder.Eval(Container.DataItem,"EmployeeID") %></td>
<td><%# DataBinder.Eval(Container.DataItem,"FirstName") %></td>
<td><%# DataBinder.Eval(Container.DataItem,"LastName") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate> </asp:repeater>
If you look at the above HTML code, it contains a simple // style="behaviour:url(sort.htc);"
// If you want to use more than behaviours then you can include
// them by separating with space character
// style ="behaviour:url(sort.htc) url(hilite.htc) url(dragdrop.htc);"
That's it! You can now do drag and drop the columns or sort the data as per particular column by clicking on header column of the table. To do drag and drop, click the mouse on any header column and drag it and drop it on another column header, and the columns get altered automatically. Also, you can highlight any particular row of data by moving mouse over that row, or select it by clicking mouse over that row. The code behind of the default.aspx is simple as it contains code to retrieve data from employee table in Points of InterestPlease note that I am returning the employee data as HTML string and storing it in a hidden Please download the demo project to see the action of the DHTML behaviors. If you face any difficulties, please contact me on my email gokuldasc@yahoo.com. Good Luck!!!
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||