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

[Solved] Dynamically populate Radgrid

1 Answer 223 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mmp
Top achievements
Rank 1
mmp asked on 12 Apr 2009, 04:39 AM
Hi,

I am trying to dynamically populate a ragdrid based on the selection of a Radtree.
I see the results from the stored procedure being populated in the variable but for some reason i cannot see it in the grid.
I am creating the radgrid at design time but no data source is assigned to it.

Here is the code: I get a message in the grid saying "No Records to display" 
I see the results in the "data" variable but nothing in the grid.

Thanks

 protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e)

    {

        var data = GetData(new SqlCommand("exec results 'Sector','Code'));

        var a = data.Rows.Count;

        var c = data.Rows[1].ToString();

        RadGrid1.DataSource = data;

        RadGrid1.Rebind();

        

    }

Here is the grid at design time:

<telerik:RadGrid ID="RadGrid1" runat="server" 

                            AllowPaging="True" AllowSorting="True" 

                            GridLines="None" Skin="Office2007" 

                            >

<MasterTableView CellSpacing="-1" AutoGenerateColumns="False">

<RowIndicatorColumn>

<HeaderStyle Width="20px"></HeaderStyle>

</RowIndicatorColumn>

<ExpandCollapseColumn>

<HeaderStyle Width="20px"></HeaderStyle>

</ExpandCollapseColumn>

</MasterTableView>

                            <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">

                                <Selecting AllowRowSelect="True" />

                            </ClientSettings>

                        </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 14 Apr 2009, 01:51 PM
Hello Mandar,

In the posted code snippet I noticed that the Rebind() method is called. This method should be used only with advanced data-binding. In the currently implemented approach you should use DataBind(), which is simple data-binding.

Best,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
mmp
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or