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

[Solved] RadGrid not displaying data

4 Answers 1060 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AAA
Top achievements
Rank 1
AAA asked on 01 May 2013, 07:22 PM
I have a radgrid on my aspx page, and it is getting data populated, however, the grid and the data are not visible on the webpage. I am attempting to do a simple databinding as shown in this example: Grid - Simple Data Binding

The source code from my aspx project is:  
<telerik:RadAjaxManager ID="RadAjaxManager2" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid1" OnSortCommand="RadGrid1_SortCommand" OnPageIndexChanged="RadGrid1_PageIndexChanged"
    Width="90%" Height="100px" OnPageSizeChanged="RadGrid1_PageSizeChanged" AllowSorting="True"
    PageSize="150" AllowPaging="True" AllowMultiRowSelection="True" runat="server"
    GridLines="None">
    <MasterTableView Height="100px" Width="100%" Summary="RadGrid table">
    </MasterTableView>
    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
</telerik:RadGrid>

Codebehind: 
private void LoadData()
{
    if (Session["TripLog"] != null)
    {
        RadGrid1.DataSource = Session["TripLog"];
        RadGrid1.DataBind();
    }
}

Any assistance is appreciated.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 May 2013, 04:13 AM
Hi,

Unfortunately i couldn't replicate any issue in your code. Here is the sample code snippet I tried.

ASPX:
<telerik:RadGrid ID="RadGrid1" AutoGenerateColumns="true" runat="server">
     <MasterTableView CommandItemDisplay="Top">
     </MasterTableView>
 </telerik:RadGrid>

C#:
public static string connection = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString3"].ConnectionString;
SqlConnection conn = new SqlConnection(connection);
public SqlCommand SqlCommand = new SqlCommand();
DataTable dt1 = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
 
    string selectQuery1 = "select top 70 OrderID,CustomerID,EmployeeID,IsTrue,ShipCity from Orders";
    SqlDataAdapter adapter1 = new SqlDataAdapter(selectQuery1, conn);
    conn.Open();
    adapter1.Fill(dt1);
    conn.Close();
    RadGrid1.DataSource = dt1;
    RadGrid1.DataBind();
}

Try using Advanced Data Binding Method if it doesn't help.

Thanks,
Princy.
0
AAA
Top achievements
Rank 1
answered on 02 May 2013, 04:11 PM
I think the issue was being caused because RadGrid1 does not like <asp:UpdatePanel> (it worked soon as I removed the UpdatePanel)

Why would RadGrid not display data is there is an UpdatePanel on the page?

Can I make the RadGrid work with an <asp:UpdatePanel> on the page ? (if I remove the UpdatePanel, the RadComboBox does a whole page submit... instead of using Ajax features)
0
Accepted
Eyup
Telerik team
answered on 07 May 2013, 08:17 AM
Hi,

Please note that using RadAjaxManager simultaneously with RadAjaxPanel or UpdatePanel ( or implementing multiple wrapped RadAjaxPanels / UpdatePanels ) is not a supported scenario and we highly recommend to avoid such implementation. Please either use just the manager to update your controls replacing the UpdatePanel with a regular asp:Panel, or use the UpdatePanel alone to wrap your page.

Furthermore, keep in mind that using DataBind() is not recommended. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, grouping, Paging, Sorting, Filtering require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
Declarative DataSource
Advanced Data Binding

Hope this helps.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
AAA
Top achievements
Rank 1
answered on 08 May 2013, 10:12 PM
Thank you for your information, Eyup.
Tags
Grid
Asked by
AAA
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
AAA
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or