﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - How can you reselect a row</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-can-you-reselect-a-row/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>How can you reselect a row</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-can-you-reselect-a-row/</link><pubDate>Fri, 04 Sep 2009 08:40:22 GMT</pubDate><dc:creator>james</dc:creator><description>&lt;p&gt;George,&lt;/p&gt;&lt;p&gt;Okay, I just realized that you're using OnTheFly configuration, which the Select in server-side may not be applicable (because the Grid wasn't refreshed in that case).&lt;/p&gt;
&lt;p&gt;You can easily achieve this scenario by using ClientAction which maybe suitable in such OnTheFly context and for best performance. Here's how:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;protected void WebGrid1_ButtonClick(object sender, ISNet.WebUI.WebGrid.ButtonEventArgs e)
    {
        SelectedObject selectedObject = WebGrid1.RetrieveClientLastSelectedObject() as SelectedObject;
        WebGrid1.ClientAction.InvokeScript("SelectRow", new FunctionParameter[] {new FunctionParameter((selectedObject.RowIndex &amp;#43; 1).ToString(), "number")});
    }&lt;/pre&gt;
&lt;p&gt;Then in your ASPX, you have the following function in your scripts:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;script type="text/javascript"&amp;gt;
    
        function SelectRow(index)
        {
            var grid = ISGetObject("WebGrid1");
            grid.RootTable.GetRow(index).Select();
        }
    
&amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;p&gt;Thus, everytime the button is clicked, it'll select the row from the server-side call (which seamlessly call to the client-side to do the real operation). I have also attached a working sample for your convenience.&lt;/p&gt;
&lt;p&gt;This is a much better solution instead of refreshing the entire Grid only to perform row selection which is very costly and results in slower response.&lt;/p&gt;
&lt;p&gt;Hope this helps,&lt;br /&gt;James.&lt;br /&gt; &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;</description></item><item><title>How can you reselect a row</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-can-you-reselect-a-row/</link><pubDate>Thu, 03 Sep 2009 21:37:59 GMT</pubDate><dc:creator>GeorgeB</dc:creator><description>&lt;p&gt;James&lt;/p&gt;&lt;p&gt;I'm not making progress. I tried your suggestion but the selected row is not selected on the client.&lt;/p&gt;
&lt;p&gt;Here's what i tried.&lt;/p&gt;
&lt;p&gt;created a gid with a button in column 1 that is used to select the row and a couple of columns of data.&lt;/p&gt;
&lt;p&gt;Clicked a button and on the server side added 1 to the selected row index.&lt;/p&gt;
&lt;p style=""&gt;On the client side i expected the row below the one that i clicked to be selected. The "&amp;gt;" is still on the row that I clicked.&lt;/p&gt;
&lt;p style=""&gt;Code in button click looks like this&lt;br /&gt;&lt;/p&gt;
&lt;p style=""&gt;Dim Selection as SelectObject = WebGrid1.RetrieveClientLastSelectedObjecct()&lt;/p&gt;
&lt;p style=""&gt;WebGrid1.RootTables.Rows(Selection.RowIndex &amp;#43; 1).Selected = True&lt;/p&gt;
&lt;p style=""&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=""&gt;the  grid button is autopostback onthefly so i've refreshed the WebGrid1 but there is no change in the selected row. &lt;br /&gt;&lt;/p&gt;
&lt;p style=""&gt;Do you have a sample? Thanks&lt;br /&gt;&lt;/p&gt;</description></item><item><title>How can you reselect a row</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-can-you-reselect-a-row/</link><pubDate>Wed, 02 Sep 2009 22:59:58 GMT</pubDate><dc:creator>james</dc:creator><description>&lt;p&gt;George,&lt;/p&gt;&lt;p&gt;You can do the row selection from server-side, although not the paging for now.&lt;/p&gt;
&lt;p&gt;For the row selection, use this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;grid.RootTable.Rows[index].Selected = true;&lt;/pre&gt;
&lt;p&gt;Let me know how it goes. &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;</description></item><item><title>How can you reselect a row</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-can-you-reselect-a-row/</link><pubDate>Wed, 02 Sep 2009 22:08:10 GMT</pubDate><dc:creator>GeorgeB</dc:creator><description>&lt;p&gt;James&lt;/p&gt;&lt;p&gt;I don't see this on the server side.&lt;/p&gt;
&lt;p&gt;George&lt;br /&gt;&lt;/p&gt;</description></item><item><title>How can you reselect a row</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-can-you-reselect-a-row/</link><pubDate>Wed, 02 Sep 2009 07:19:58 GMT</pubDate><dc:creator>james</dc:creator><description>&lt;p&gt;George, assuming that you keep the page index and the row value to be reselected, you can do the following.&lt;/p&gt;&lt;p&gt;To go to a specific page, use&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;grid.GotoPage(pageIndex);&lt;/pre&gt;
&lt;p&gt;To go to a specific row by key value (assuming the row existed in the page), you can use:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;var row = grid.RootTable.GetRowByKeyValue("ALFKI");
if (row != null)
     row.Select();&lt;/pre&gt;
&lt;p&gt;Hope this helps,&lt;br /&gt;James.&lt;br /&gt; &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;</description></item><item><title>How can you reselect a row</title><link>http://www.intersoftsolutions.com/Community/WebGrid/How-can-you-reselect-a-row/</link><pubDate>Tue, 01 Sep 2009 22:04:35 GMT</pubDate><dc:creator>GeorgeB</dc:creator><description>&lt;p&gt;Let's say I select a row. Do a bunch of things (change page, etc.) and then want to display the grid and position back at the same page and same row.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;We are using classic paging with 100 items on a page. &lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Your help is appreciated.&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>