Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / get selected row index in webdatagrid

get selected row index in webdatagrid

New Discussion
xinde
xinde asked on Dec 5, 2012 12:31 PM

I have trouble to get selected row index in webdatagrid.  here is the code:

 

 

 

 

 

 

 

 

 

 

 

function WebDataGridView_CellSelectionChanged(webDataGrid, evntArgs) {

 

 

 

var grid = $find(“<%=WebDataGrid1.ClientID%>”);

var rows = grid.get_rows();

 

 

 

var row = rows.get_row(1); // 1 = your row index

 

 

 

var cellValue = row.get_cell(1).get_value(); // 0 = your cell index

alert(cellValue);

}

 

The above code works. But I want to get the selected row index. So I use the following code:

 

 

var newSelectedCell = eventArgs.getSelectedCells().getItem(0);

var row = newSelectedCell.get_row();

 

 

 

var rowIndex = row.get_index();

However, I get error. Can you please help me to get the selected row index. Thanks.

Sign In to post a reply

Replies

  • 0
    Edward
    Edward answered on Mar 27, 2011 2:49 AM

    Hi,

    Once you have the row you can use:

    gridrow._index

    Ed

    • 0
      xinde
      xinde answered on Mar 27, 2011 3:24 PM

      Thanks for help. I don't have row. but I have the rows by using grid object. I try to get the selected index to get that selected row.

      I used ultraGrid before. The way to get it is:

      var row = igtbl_getRowById(cellID);

      I don't know get the selected row in webdatagrid.

      • 0
        Edward
        Edward answered on Mar 27, 2011 3:39 PM

        Hi,

        After the line:

        var row = newSelectedCell.get_row();

        you then have the row. Then you can use:

        row._index

        to get the index of that row. 

        Ed

      • 0
        Abhishek
        Abhishek answered on Sep 17, 2011 11:07 PM

        Hi , Following code can help in getting the Current selected Row Index in Server Side

        string currentRowIndex = this.WebDataGrid1.Behaviors.Activation.ActiveCell.Row.Index.ToString();
        
        
        
        Thanks,
        Abhishek

  • 0
    Aparna
    Aparna answered on Dec 5, 2012 12:31 PM

    Hello,

    I had the same problem. On row selection I wanted the row index. The solution I found out is like this –

    eventArgs.getSelectedRows()._keys.length – 1].index

    here length – 1 because the keys array stores all the selected row indices in case you have allow multiple select = true. So length – 1 will give the latest selected row index.

    Thanks

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
xinde
Favorites
0
Replies
5
Created On
Dec 05, 2012
Last Post
13 years, 9 months ago

Suggested Discussions

Created by

Created on

Dec 5, 2012 12:31 PM

Last activity on

Feb 18, 2026 2:24 PM