Updating textbox based on RadGrid selection

2 posts, 0 answers
  1. Scott
    Scott avatar
    22 posts
    Member since:
    Aug 2012

    Posted 20 Nov 2013 Link to this post

    I am using a RadGrid and want to be able to show row specific details in another item (such as a TextBox) when a row is clicked.  This is similar to the example seen in this Grid Example.  Since the Grid Example does not have details I am using the example in Grid Row Selection.  I want the selection to work like the top example, not the bottom one.  I am trying to have the JavaScript call a method in the aspx.cs page that then updates a text box, but the PageMethods.RowClick method in the code behind is static so it does not have access to TextBox1.  Is it possible to have more control in the aspx.cs page?  The first example looks to be using previously generated items that are then hidden or exposed using JavaScript.  Is that what I need to be doing?   

    I basically want the user to be able to click on a row in the RadGrid and have other things on the page update immediately based on the selected row.               

    function RadGrid1_OnRowClick(sender,eventArgs)
           var MasterTable = sender.get_masterTableView();
           var Name = MasterTable.getCellByColumnUniqueName(row, "Server").innerHTML;
    // radgrid.aspx.cs
        public static void RowClick(string item)
            TextBox1.Text += item;
  2. Steve Lassanske
    Steve Lassanske avatar
    5 posts
    Member since:
    Sep 2007

    Posted 20 Nov 2013 Link to this post

    Side Note: On the control overview page where the source code is hidden, you can un-hide it by clicking on "view source" at the top of the page. It doesn't look like a clickable link, but it is. :)

    I believe the example that more resembles what you're trying to achieve is the Master/Detail example (http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/master-detail/defaultcs.aspx). This is where you click on a row in the top (Customer) grid and it relationally populates the bottom two grids. The difference for you is that instead of using the bottom two grids' data source relationships to repopulate, you'll use the main grid's ItemCommand event in the code behind to get the column values from the sender and write them where ever you want. Be sure to include your target control (e.g., textbox) in your RadAjaxManager's AjaxUpdatedControl with your grid as your AjaxSetting control.
Back to Top