Selected row cell value in raggrid

3 posts, 0 answers
  1. sho
    sho avatar
    24 posts
    Member since:
    Mar 2007

    Posted 04 Aug 2011 Link to this post

    Hi,

    My aspx page has radgrid and a dropdownlist. I want to populate this dropdownlist based on the value captured from a cell on selecting a single radgrid row.

    I have set AllowMultiRowSelection ="false"  and on clientsettings <Selecting AllowRowSelect="True"></Selecting>.

    How can I do this?

    Or if am using <ClientEvents OnRowSelected="RowSelected" /> and call some javascript I can get the cell value. How will I make use of this to populate the dropdown. The dropdown population is in codebehind.

    Thanks,
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 04 Aug 2011 Link to this post

    Hello,

    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource"
               OnItemCommand="RadGrid1_ItemCommand">
               <MasterTableView  DataKeyNames="ID">
                   <Columns>
                       <telerik:GridBoundColumn UniqueName="ID" HeaderText="ID" DataField="ID">
                       </telerik:GridBoundColumn>
                   </Columns>
               </MasterTableView>
               <ClientSettings EnablePostBackOnRowClick="true">
                   <Selecting AllowRowSelect="true" />
               </ClientSettings>
           </telerik:RadGrid>
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == "RowClick" && e.Item is GridDataItem)
            {
                string strIdColumnText = ((GridDataItem)e.Item)["ID"].Text;
                // e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"]; // You can also take Id from DataKey
                BindCombo(strIdColumnText);
            }
        }
     
        protected void BindCombo(string strValue)
        {
            // Bind your combo here
        }

    let me know if this is not your case.

    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Aug 2011 Link to this post

    Hello sho,

    Try the following scenario using RadAjaxManager to populate DropDownList.
    JS:
    <script type="text/javascript">
    function RowSelected(sender, eventArgs)
    {
        var grid = sender;
        var MasterTable = grid.get_masterTableView(); var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
        var cell = MasterTable.getCellByColumnUniqueName(row, "EmployeeID");
        $find("<%=RadAjaxManager1.ClientID%>").ajaxRequest(cell.innerHTML);
    }
    </script>
    aspx:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    </telerik:RadAjaxManager>
    C#:
    protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
       string val=e.Argument;
       binddropdown();
    }
    protected void binddropdown(string strvalue)
      {
         //Bind your dropdown here
      }

    Thanks,
    Shinu.
Back to Top