having 2 GridTempelateColumn in a radgrid

I have a radgrid with 2 GridTempelateColumn. There is a link button in both columns. i want to access the value of 1 link button when i click on the other link button. Is it possible?

1 answer

  • answered 2018-09-21 07:35 Mennan

    Set a unique name to templatecolumn and find by unique name:

    client side:

    function OnClientClick()
    {
      var master = $find('<%= RadGrid1.ClientID %>').get_masterTableView();
      var row = master.get_dataItems()[0];
      var cell = master.getCellByColumnUniqueName(row, "UniqueName");
      alert(cell.innerHTML);
    }
    

    server side:

    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
    {
       LinkButton btnLink= (LinkButton)item.FindControl("controlName");
    }
    

    server side alternative:

    var tableView = RadGrid1.OwnerTableView;
    var gridColumn = tableView.Columns.FindByUniqueNameSafe(uniqueName);
    if (gridColumn != null)
        {
            var cell = gridDataItem[gridColumn];
        }