This is a migrated thread and some comments may be shown as answers.

Updating textbox based on RadGrid selection

1 Answer 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 20 Nov 2013, 10:34 PM

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.               


//radgrid.aspx
function RadGrid1_OnRowClick(sender,eventArgs)
{
       var MasterTable = sender.get_masterTableView();
       var Name = MasterTable.getCellByColumnUniqueName(row, "Server").innerHTML;
       PageMethods.RowClick(Name);
}
 
// radgrid.aspx.cs
   [System.Web.Services.WebMethod]
    public static void RowClick(string item)
    {
        TextBox1.Text += item;
    }

1 Answer, 1 is accepted

Sort by
0
Steve Lassanske
Top achievements
Rank 1
answered on 20 Nov 2013, 11:29 PM
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.
Tags
Grid
Asked by
Scott
Top achievements
Rank 1
Answers by
Steve Lassanske
Top achievements
Rank 1
Share this question
or