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

[Solved] Controls in NoRecordsTemplate

1 Answer 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sanoj
Top achievements
Rank 1
Sanoj asked on 29 Oct 2009, 09:02 AM
I want to put a button in the NoRecordsTemplate of a grid
Unfortunately the code-behind doesn' t recognize the ID of the button(Error    The name 'cmdButton' does not exist in the current context)

<NoRecordsTemplate> 
   <asp:Button ID="cmdButton" /> 
</NoRecordsTemplate> 

cmdButton.Visible = false
 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Oct 2009, 11:04 AM
Hello Sanoj,

You can try out the following code to access the button nested inside the NoRecordsItemTemplate:
c#:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        GridNoRecordsItem noItem = (GridNoRecordsItem)RadGrid1.MasterTableView.GetItems(GridItemType.NoRecordsItem)[0]; 
        Button btn = (Button)noItem.FindControl("cmdButton"); 
        btn.Visible = false
    } 

Thanks
Princy.
Tags
Grid
Asked by
Sanoj
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or