RadGridView null inside a custom user control

Posted by Community Admin on 04-Aug-2018 13:55

RadGridView null inside a custom user control

All Replies

Posted by Community Admin on 19-May-2011 00:00

Hello,
I'm writing a custom control and got problem with a null value for the RadGridView (and also others controls)
Here's my ascx :

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SearchPage.ascx.cs"
    Inherits="SitefinityWebApp.SearchPage" %>
<%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %>
<%@ Register TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit"
    Assembly="Telerik.Sitefinity" %>
<div id="itemsContainer" runat="server">
<asp:Label runat="server" Text="prova" ID="jason"></asp:Label>
    <telerik:RadGrid runat="server" ID="gvResult" AutoGenerateColumns="false">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn UniqueName="FileName" DataField="Title">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="DateCreated" DataField="DateCreated">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn UniqueName="FileName" DataField="Title">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
</div>

and here's the cs:

public partial class SearchPage : System.Web.UI.UserControl
   
       private string queryString = string.Empty;
       private bool searchTagOnly = false;
 
       protected void Page_Load(object sender, EventArgs e)
       
           if (Request.Params["query"] != null)
           
               queryString = Request.Params["query"];
           
 
           if (Request.Params["tag"] != null)
           
               searchTagOnly = Convert.ToBoolean(Request.Params["tag"]);
           
 
 
           PerformSearch();
       


when I do

gvResult.DataSource = result; <- gvResult is null and also this.Controls has 0 items...
gvResult.DataBind();

Why this happen?
Thanks

Posted by Community Admin on 23-May-2011 00:00

Hello Paolo,

Thanks for the code, but it doesn't show where you create and set value of the "result" . Can you show how you set this value?

Best wishes,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed