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

this.findcontrol (RadGrid1) returns null

3 Answers 186 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jeeva
Top achievements
Rank 1
jeeva asked on 06 Jan 2009, 05:07 AM

 

Hi !

this.findcontrol(RadGrid1) returns null in my cs file.  i have enclose my aspx file cs file statements for u r view.








<

asp:Content ID="cntBody" ContentPlaceHolderID="cntBody" runat="server">

 

 

<%

@ Register Assembly ="Telerik.Web.UI" Namespace ="Telerik.Web.UI" TagPrefix ="telerik"%>

 

<

script type="text/javascript">

 

 

 

var grid;

 

 

 

 

function

RowSelected(rowObject)

 

{

 

var selRow = this.GetCellByColumnUniqueName(rowObject,"itemcode");

 

 

//here selRow.innerHTML will hold the value for the selected row contact name

 

 

 

 

 

SelectOrder(selRow.innerHTML,selRow.innerHTML);

}

 

 

function

SelectOrder(sPARENT_ID, sPARENT_NAME)

 

{

 

 

if ( window.opener != null && window.opener.ChangeItemcode != null )

 

{

window.opener.ChangeItemcode(sPARENT_ID, sPARENT_NAME);

window.close();

}

 

else

 

 

 

{

alert(

'Original window has closed. Trims cannot be select' );

 

}

}

 

 

function

GridCreated()

 

{

grid =

this;

 

}

 

</

script>

 

 


 

 

<telerik:RadGrid ID ="RadGrid1" runat ="server" AutoGenerateColumns ="false" AllowPaging ="true"

 

 

 

 

allowsorting ="true" AllowFilteringByColumn ="true" Width ="500px" OnItemCommand ="RadGrid1_ItemCommand"

 

 

 

 

OnNeedDataSource="RadGrid1_NeedDataSource"

 

 

oncolumncreating="RadGrid1_ColumnCreating" >

 

 

 

 

<MasterTableView AllowFilteringByColumn ="true" >

 

 

 

 

</MasterTableView>

 

 

 

 

<PagerStyle Mode ="NumericPages" />

 

 

 

 

<ClientSettings >

 

 

 

 

<Selecting AllowRowSelect ="true" />

 

 

 

 

 

</ClientSettings>

 

 

 

 

</telerik:RadGrid>

 

 

 

 

 

<br/>

 

 

 

 

<asp:Button ID="clrFilters" runat="server" Text="Clear filters"></asp:Button>

 

 

 

 

</asp:Content>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
My CS file .

 

 

protected void Page_Load(object sender, System.EventArgs e)

 

{

 

 

if (!IsPostBack)

 

{

Telerik.Web.UI.

RadGrid RadGrid1 = this.FindControl("RadGrid1") as Telerik.Web.UI.RadGrid;

 

ds = GetDataSet(

"SELECT Country, City, Index FROM Customers");

 

 

// this.RadGrid1.MasterTableView.Columns.Clear();

 

 

 

 

RadGrid1.MasterTableView.Columns.Clear();

 

 

try

 

 

 

 

{

RadGrid1.DataSource = ds;

 

}

 

catch (Exception e1)

 

{

}

 

 

foreach (DataColumn dataColumn in ds.Tables[0].Columns)

 

{

RadGrid.

MyCustomFilteringColumnCS gridColumn = new RadGrid.MyCustomFilteringColumnCS();

 

RadGrid1.MasterTableView.Columns.Add(gridColumn);

gridColumn.DataField = dataColumn.ColumnName;

gridColumn.HeaderText = dataColumn.ColumnName;

}

}

}

 


 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Jan 2009, 08:13 AM
Hi Jeeva,

Try the accessing the Grid as shown below and see if it is working.

CS:
        RadGrid Grid = this.RadGrid1 as RadGrid; 


Shinu
0
jeeva
Top achievements
Rank 1
answered on 07 Jan 2009, 06:29 AM
Hi Shinu !

      Thx for u reply. i already tried this one also but results the same problem
0
jeeva
Top achievements
Rank 1
answered on 07 Jan 2009, 11:57 AM
hi Shinu !
   Now i found the solution place the radgrid inside the content panel.



ContentPlaceHolder

cp = (ContentPlaceHolder)Page.Form.FindControl("cntBody");

 

 

Telerik.Web.UI.

RadGrid RadGrid1 = cp.FindControl("RadGrid1") as Telerik.Web.UI.RadGrid;

 


 
Tags
Grid
Asked by
jeeva
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
jeeva
Top achievements
Rank 1
Share this question
or