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

How to get all Radgrid Data into a datatable when the RadGrid has GridTemplateColumn?

1 Answer 356 Views
Grid
This is a migrated thread and some comments may be shown as answers.
shemein
Top achievements
Rank 1
shemein asked on 08 Apr 2014, 03:41 PM
I want to get all data of a Radgrid into a datatable but my Radgrid includes GridTemplateColumn and when I use the normal code to get the column and rows in a datatable it gets back some of bound columns empty. Would you please help me to know what should I do?



1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 09 Apr 2014, 11:59 AM
Hi Zahra,

Can you please share with us the code you use to get the column and rows in a datatable? For more information about accessing grid cells and rows I would recommend you examine this help article:
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

For example if you have the following template column declaration:
<telerik:GridTemplateColumn UniqueName="TemplateColumn">    
   <ItemTemplate>   
      <%#Eval("City") %>               
   </ItemTemplate>   
</telerik:GridTemplateColumn>

and you want to access this column value you can use the following code inside ItemDataBound server-side event:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
   
       if (e.Item is GridDataItem) 
       
           string City= ((DataRowView)e.Item.DataItem)["City"].ToString();
       }
   }

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
shemein
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or