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

How do I reference thje grid when using a template?

3 Answers 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albert
Top achievements
Rank 1
Albert asked on 11 Sep 2008, 03:16 AM
My acsx file has a RadGrid that has
- MasterTableView
    - DetailTable, which uses a template.

I need to get something from the grid while im on the Load of theDetail View template

      

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Sep 2008, 05:24 AM
Hello Albert,

Try out the following code snippet to achieve the required.
ascx:
       <MasterTableView>                
          <DetailTables> 
              <telerik:GridTableView Name="Detail" AutoGenerateColumns="false" DataSourceID="SqlDataSource1"
                <Columns> 
                <telerik:GridBoundColumn DataField="SupplierID"  HeaderText="SupplierID" SortExpression="SupplierID" 
                        UniqueName="ID"
                </telerik:GridBoundColumn> 
                </Columns> 
              </telerik:GridTableView> 
           </DetailTables> 
        </MasterTableView>  

ascx.cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Detail") 
        { 
           GridDataItem dataitem=(GridDataItem)e.Item; 
           string strtx = dataitem["ID"].Text; 
        } 
    } 

Princy.
0
Albert
Top achievements
Rank 1
answered on 11 Sep 2008, 06:31 AM
Thanks but that wont work. Here's a sample code on an ascx file name test1

<%@ Register src="test2.ascx" tagname="Test" tagprefix="control" %>

<telerik:RadGrid
       <MasterTableView
           <DetailTables>
          <telerik:GridTableView>
          <NoRecordsTemplate>
              <control:Test ID="Test" runat="server" />
            </NoRecordsTemplate>
....

How Do I reference the Grid on the test1.ascx from the test2.ascx?

0
Anwar at NVizionSoft
Top achievements
Rank 1
answered on 11 Sep 2008, 10:42 AM
I am having the same issue...  I have a button I am including in the NoRecordsTemplate which says "Add New Service Plan", but I want to be able to hide this button when I don't want the user to be able to perform this operation.  Wondering how to access the control from my server side code.
Tags
Grid
Asked by
Albert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Albert
Top achievements
Rank 1
Anwar at NVizionSoft
Top achievements
Rank 1
Share this question
or