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

GridTableView row count

3 Answers 238 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Maxime
Top achievements
Rank 1
Maxime asked on 22 Jan 2013, 07:04 PM
In my grid table view, I want to have my last column to take the span of all the rows in the tableview.

In order to do this, I need to be able to loop through all the rows of the gridtableview but when I try the following in my DetailTableDataBind : 

e.DetailTableView.Items.Count

it always returns 0.

What can I do in order to achieve this?

Thanks

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Jan 2013, 03:29 AM
Hello,

protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
    {
        // Access Parent Item here
        //e.DetailTableView.ParentItem.OwnerTableView.Items
    }

How to access parent and child items in prerender event.
http://www.telerik.com/community/code-library/aspnet-ajax/grid/accessing-and-validating-controls-client-side-inside-a-hierarchical-radgrid.aspx

In DetailTableDataBind we are assigning the Dataource to the child table so we can not get items.count in this event.

http://www.telerik.com/help/aspnet-ajax/grid-control-lifecycle.html
http://www.telerik.com/help/aspnet-ajax/grid-event-sequence.html
http://www.telerik.com/help/aspnet-ajax/events_t_telerik_web_ui_radgrid.html

Thanks,
Jayesh Goyani
0
Accepted
Shinu
Top achievements
Rank 2
answered on 23 Jan 2013, 05:55 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void grid_PreRender(object sender, EventArgs e)
{
     foreach (GridDataItem dataItem in grid.MasterTableView.Items)
     {
          int count = dataItem.ChildItem.NestedTableViews[0].Items.Count;
    }
 }

Thanks,
Shinu
0
Maxime
Top achievements
Rank 1
answered on 23 Jan 2013, 02:43 PM
Thank you both for your answers.

Shinu, this is exactly what I needed thank you very much.

Jayesh, those are very good articles that I will read in more depth. Thank you!
Tags
Grid
Asked by
Maxime
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Maxime
Top achievements
Rank 1
Share this question
or