ComponentOne GridView for ASP.NET WebForms
Task-Based Help / Tracking the Current Cell Position
In This Topic
    Tracking the Current Cell Position
    In This Topic

    By default client-side selection information is unavailable on the server. However, you can track when the current cell position changes and send this data to server at postback.

    For example, complete the following steps:

    1. Add the following script to your application's markup:
         <script type="text/javascript">
      function onCurrentCellChanged(e, args) {
      $("#currentCellValue").val($(e.target).c1gridview("currentCell").value());
      }
      </script>
    2. Edit the C1GridView control's markup so it appears similar to the following:
      <cc1:C1GridView ID="C1GridView1" runat="server" DataSourceID="AccessDataSource1" AutogenerateColumns="false"
          OnClientCurrentCellChanged="onCurrentCellChanged">
      <Columns>
      <cc1:C1BoundField DataField="OrderID" HeaderText="OrderID" />
      <cc1:C1BoundField DataField="Quantity" HeaderText="Quantity" />
      </Columns>
      </cc1:C1GridView>
    3. Right-click the window and select View Code to switch to Code view.
    4. Add the following code to the Page_Load event in your application:

      To write the code in Visual Basic:

        
      Visual Basic
      Copy Code
      Page.ClientScript.RegisterHiddenField("currentCellValue", Nothing)
       If IsPostBack Then
        Dim currentCellValue As String = Page.Request("currentCellValue")
       End If

      To write the code in C#:

      C#
      Copy Code
      Page.ClientScript.RegisterHiddenField("currentCellValue", null);
       if (IsPostBack)
       {
           string currentCellValue = Page.Request["currentCellValue"];
       }

    This code allows you to track when the current cell position changes and send this data to server at postback.

    See Also