5 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 08 Apr 2009, 07:10 AM
Hello Christian,
I'm not clear as to where you have placed your grid. But if you want to access the grid when you kow its ID then you can use the FindControl method:
C#:
Thanks
Princy.
I'm not clear as to where you have placed your grid. But if you want to access the grid when you kow its ID then you can use the FindControl method:
C#:
| protected void Page_Load(object sender, EventArgs e) |
| { |
| RadGrid grid = (RadGrid)Page.FindControl("RadGridID"); |
| } |
Thanks
Princy.
0
Christian
Top achievements
Rank 1
answered on 08 Apr 2009, 08:46 AM
I've tried this function but I get back grid = nothing ?!
Christian
Christian
0
Shinu
Top achievements
Rank 2
answered on 08 Apr 2009, 10:13 AM
Hi Christian,
The above given code will work fine if you have placed the Grid in a page with its ID as RadGrid1. Check whether you have placed the Grid normally in a page or in a usercontrol and also check whether you are accessing the Grid using its correct ID. If this does not help consider sending the entire aspx code.
Thanks
Shinu
The above given code will work fine if you have placed the Grid in a page with its ID as RadGrid1. Check whether you have placed the Grid normally in a page or in a usercontrol and also check whether you are accessing the Grid using its correct ID. If this does not help consider sending the entire aspx code.
Thanks
Shinu
0
Christian
Top achievements
Rank 1
answered on 15 Apr 2009, 07:18 AM
We use the RadGrid in a Usercontrol:
The RadGrid itsself is created with codr behind:
It doesn't work with:
Anny Idea?
Thanks
Christian
<
asp:HiddenField ID="ViewState_RG0" runat="server" Value="" />
<div id="D_0" runat="server" class="" style="width: 110px; margin-top: 2px; overflow: hidden; |
| display: inline; text-align: right"> |
| <rc:HeaderContainer ID="D_01" runat="server" HeaderText=" " Width="100%" ControlsDir="~/rcControls/HeaderContainer"> |
| <asp:PlaceHolder ID="PlaceHolder0" runat="server" /> |
| </rc:HeaderContainer> |
| </div> |
The RadGrid itsself is created with codr behind:
| Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init |
| CreateGrid() |
| End Sub |
| Private Sub CreateGrid(ByVal Index As Integer) |
| dim g as RadGrid |
| ' build RadGrid |
| ' do something amazing |
| Me.PlaceHolder0.Controls.Add(g) |
| Me.ViewState_RG0.Value = g.ClientID |
| RadGrid0_ClientID = g.ClientID |
| End Sub |
| Public Property RadGrid0_ClientID() As String |
| Get |
| Return CStr(Me.ViewState("RadGrid0_ClientID")) |
| End Get |
| Set(ByVal value As String) |
| Me.ViewState("RadGrid0_ClientID") = value |
| End Set |
| End Property |
It doesn't work with:
| g = new RadGrid(); |
| g = DirectCast(FindControl(RadGrid0_ClientID), com.regiocom.Web.UI.WebControls.TelerikGrid) |
| g = DirectCast(FindControl(Me.ViewState_RG0.Value), com.regiocom.Web.UI.WebControls.TelerikGrid) |
Anny Idea?
Thanks
Christian
0
Shinu
Top achievements
Rank 2
answered on 15 Apr 2009, 11:13 AM
Hi Christian,
Since the RadGrid is inside the UserControl try accessing the Grid from the UserControl as shown below.
VB:
Thanks
Shinu
Since the RadGrid is inside the UserControl try accessing the Grid from the UserControl as shown below.
VB:
| //try accessing the webusercontrol using the correct ID |
| Dim Grid As RadGrid = DirectCast(WebUserControl1.FindControl("RadGrid1"), RadGrid) |
Thanks
Shinu