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

About rad grid

1 Answer 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul Khinvasara
Top achievements
Rank 1
Rahul Khinvasara asked on 05 Nov 2008, 02:04 PM
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.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Nov 2008, 05:35 AM
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.
Tags
Grid
Asked by
Rahul Khinvasara
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or