Intersoft WebGrid Documentation
Walkthrough: Using OnCellClick and OnRowSelect events in NewRow
See Also Send comments on this topic.

Glossary Item Box

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:

 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

  1. Binding WebGrid to AccessDataSource.
  2. Right click on WebGrid and choose WebGrid.Net Designer.
  3. Select the AllowAddNew checkbox.
  4. In the WebGrid InitializeLayout server side event, put the following code:

    C# Copy ImageCopy Code
    private void WebGrid1_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e)
    {
            e.Layout.ClientSideEvents.OnRowSelect = "DoRowSelect";
            e.Layout.ClientSideEvents.OnCellClick = "DoCellClick";
    }
    

  5. Write some javascript functions in the client side:

    JavaScript Copy ImageCopy 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;
    }

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.