One grid updating another grid

2 posts, 0 answers
  1. DJ
    DJ avatar
    14 posts
    Member since:
    Jan 2008

    Posted 19 Mar 2009 Link to this post

    I'm wondering what is the best or easiest way to accomplish the following.

    I have 2 RadGrids on a single page.  I want any row click event in RadGrid1 refresh RadGrid2.  I don't have a datasource object on the aspx page, so I need it all to happen in the code behind.  I also need a DataKeyValue from RadGrid1 that I will use when creating the new contents of RadGrid2.

    I've seen example of stuff close to this but not exactly this.  I have been trying to get this done with an AjaxManager - but maybe I'm better off not using that?

    Any simple examples would be wonderful.  Thanks for the help.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Mar 2009 Link to this post

    Hello DJ,

    You can loop through the rows of the first grid on its SelectedIndexChanged event and check if the row is selected and then retrieve its key value based on which you can populate your second grid.To understand better check out the code below:
     protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e) 
            foreach (GridDataItem item in RadGrid1.Items) 
                if (item.Selected) 
                   string strtxt = item.GetDataKeyValue("ProductName").ToString(); 
                   if (strtxt == "Chai"
                       RadGrid2.DataSource = new string[] {"aa","bb" };//set datasource here 

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top