This walkthrough shows you how to specify the OnCellClick and OnRowSelect events in NewRow.
During this walkthrough, you will learn how to do the following:
- Manipulate the grid client side to attach OnRowSelect and OnCellClick in grid.
Prerequisites
In order to complete this walkthrough, you will need the following:
- Access to the Microsoft Access Northwind database.
- Visual Studio 2005 Application.
Step-By-Step Instructions
- Binding WebGrid to AccessDataSource.
- Right click on WebGrid and choose WebGrid.Net Designer.
- Select the AllowAddNew checkbox.
- In the WebGrid InitializeLayout server side event, put the following code:
C# Copy Code private void WebGrid1_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e) { e.Layout.ClientSideEvents.OnRowSelect = "DoRowSelect"; e.Layout.ClientSideEvents.OnCellClick = "DoCellClick"; }
-
Write some javascript functions in the client side:
JavaScript Copy Code function DoRowSelect(gridId, tblName, rowIdx, rowElm)
{
alert("OnRowSelect : WebGridId = " + gridId + " TableName = " + tblName + " RowIndex = " + rowIdx + " RowElement = " + rowElm);
return true;
} function DoCellClick(gridId, tblName, rowIdx, cellIdx, cellElm)
{
alert("OnCellClick : WebGridId = " + gridId + " TableName = " + tblName + " RowIndex = " + rowIdx + " CellIndex = " + cellIdx + " CellElement = " + cellElm);
return true;
}
References
OnCellClick Property
OnRowSelect Property
InitializeLayout Event
Other Resources
Walkthrough Topics
How-to Topics