About rad grid

2 posts, 0 answers
  1. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 05 Nov 2008 Link to this post

    Hi,

    I am using hierarchical grid.In this in commandItemTemplate i have one link button.Instead of having on grid row i want this linkbutton below each row of the parent grid.On this link btn i want to show popup form.and to this popup i wat to send the id of first row of grid.
                    If we are having link button on grid row itself then it is easy to pass the grid row id to link button.But as my link btn is nt on grid  i am  not able to pass the id of first row of grid.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Nov 2008 Link to this post

    Hi Rahul,

    You can set the required ID field as the DataKeyName and access it in the click event of the LinkButton as shown below.

    ASPX:
    <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="ID"  Name="Master"  > 
     <DetailTables> 
      <telerik:GridTableView runat="server"  Name="Detail"  DataKeyNames="ID"  DataSourceID="SqlDataSource1" CommandItemDisplay="Top" AutoGenerateColumns="true" > 
      <CommandItemTemplate> 
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton> 
      </CommandItemTemplate> 
          


    CS:
    protected void LinkButton1_Click(object sender, EventArgs e) 
        { 
            //to access from the Parent table 
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
            { 
              //to get the datakeyName 
                string rowID = item.GetDataKeyValue("ID").ToString(); 
             //to get the row index 
                int rowIndex = item.ItemIndex; 
                 
     
                break; 
            } 
     
           //to access from the Child table 
            LinkButton lnkbtn=(LinkButton)sender; 
            GridCommandItem cmdItem = (GridCommandItem)lnkbtn.NamingContainer; 
            GridTableView ChildTable = (GridTableView)cmdItem.OwnerTableView; 
            foreach (GridDataItem childItem in ChildTable.Items) 
            { 
                //to get the datakeyName 
                string rowID = childItem.GetDataKeyValue("ID").ToString(); 
                //to get the row index 
                int rowIndex = childItem.ItemIndex;  
                  
                break; 
            } 
     
        } 


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