Click here to Skip to main content
15,891,902 members
Articles / Web Development / XHTML

Paging, Selecting, Deleting, Editing and Sorting in the ASP.NET GridView Control with Keyboard Shortcuts

Rate me:
Please Sign up or sign in to vote.
4.89/5 (32 votes)
5 Oct 2010CPOL8 min read 158K   6.3K   137  
An ASP.NET 2.0 AJAX Extender to enhance the ASP.NET GridView to page, select, delete, edit and sort rows with keyboard shortcuts.
<?xml version="1.0" encoding="utf-8"?>
<Languages>
	<Language Name="English">
		<SystemTexts>
      <NoFilterText>All</NoFilterText>
			<SystemArray Name="textpick" desc="populate filter select options">
				<Item Name="A"/>, <Item Name="B"/>, <Item Name="C"/>, <Item Name="D"/>, <Item Name="E"/>, <Item Name="F"/>, 
				<Item Name="G"/>, <Item Name="H"/>, <Item Name="I"/>, <Item Name="J"/>, <Item Name="K"/>, <Item Name="L"/>, 
				<Item Name="M"/>, <Item Name="N"/>, <Item Name="O"/>, <Item Name="P"/>, <Item Name="Q"/>, <Item Name="R"/>, 
				<Item Name="S"/>, <Item Name="T"/>, <Item Name="U"/>, <Item Name="V"/>, <Item Name="W"/>, <Item Name="X"/>, 
				<Item Name="Y"/>, <Item Name="Z"/>
			</SystemArray>
      <SystemArray Name="datepick" desc="populate filter select options">
        <Item Name="Today"/>,<Item Name="Tomorrow"/>,<Item Name="Yesterday"/>,
        <Item Name="This week"/>,<Item Name="Next week"/>,<Item Name="Last week"/>,
        <Item Name="This month"/>,<Item Name="Next month"/>,<Item Name="Last month"/>,
        <Item Name="This quarter"/>,<Item Name="Next quarter"/>,<Item Name="Last quarter"/>,
        <Item Name="This year"/>,<Item Name="Next year"/>,<Item Name="Last year"/>
      </SystemArray>
      <SystemArray Name="boolpick" desc="boolean selection">
        <Item Name="Y"/>,
        <Item Name="N"/>
      </SystemArray>
    </SystemTexts>
    
		<AjaxGrids>
			<AjaxGrid Name="masterbacklog" Height="200" DbTable="tblMasterBacklog" DBIdField="MasterBacklogID">
        <SQL>
          SELECT
          tblMasterBacklog.MasterBacklogID,
          tblProducts.ProductName as Product,
          tblMasterBacklog.CustomerScenario as Scenario,
          tblMasterBacklog.Feature as Feature,
          tblMasterBacklog.Activity as Activity,
          tblMasterBacklog.Description as Description,
          tblMasterBacklog.ProductPriority as Priority,
          tblMasterBacklog.Hours,
          tblMasterBacklog.FeatureComplete as Complete,
          tblMasterBacklog.ShowInMB as MB,
          tblMasterBacklog.ProductRank,
          tblMasterBacklog.MasterRank
          FROM tblMasterBacklog
          INNER JOIN tblProducts ON tblMasterBacklog.fProductID = tblProducts.ProductID
          WHERE 1=1 -- we need at least one condition, because filters will append dynamically to this query
        </SQL>
        <Columns>
					<Column Type="Dropdown" Width="200" GridDbField="fProductID" SortName="ProductName" Header="Product" Editable="y">
						<UpdateSQL>Update tblMasterBacklog SET fProductID=@value WHERE MasterBacklogID=@id</UpdateSQL>
						<SelectOptionsSQL>SELECT tblProducts.ProductID as Id, tblProducts.ProductName as Value FROM tblProducts </SelectOptionsSQL>
					</Column>
					<Column Type="Text" Width="60" GridDbField="CustomerScenario" Header="Scenario" Editable="y"/>
					<Column Type="Text" Width="160" Header="Feature" Editable="y"/>
					<Column Type="Text" Width="120" Header="Activity" Editable="y"/>
					<Column Type="Text" Width="120" Header="Description" Editable="y"/>
					<Column Type="Text" Width="70" GridDbField="ProductPriority" Header="Priority" Editable="y"/>
					<Column Type="Float" Width="70" Header="Hours" Editable="y"/>
					<Column Type="Boolean" Width="80" GridDbField="FeatureComplete" Header="Complete" Editable="y"/>
					<Column Type="Boolean" Width="70" GridDbField="ShowInMB" Header="MB" Editable="y"/>
					<Column Type="Float" Width="80" Header="ProductRank" Editable="y"/>
					<Column Type="Float" Width="80" Header="MasterRank" Editable="y"/>
				</Columns>
				<FreeText>
					CONTAINS(tblMasterBacklog.*, '"@freeTextFilter*"') OR
					CONTAINS(tblProducts.ProductName, '"@freeTextFilter*"')
				</FreeText>
			</AjaxGrid>
		</AjaxGrids>
	</Language>
</Languages>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Dipl.-Ing. Rolf Cerff Software Development and IT-
Germany Germany
I'am a freelance software developer, located at Freiburg i. Br., Germany. My main domain is designing and developing Web applications based on the ASP.NET technology. Further main interests are. Sustainable and agile software architectures, Domain Driven Design (DDD). I'am a certified SCRUM Master.

Comments and Discussions