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

Retrieving data from RadGrid's Template Column

4 Answers 404 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Al Safavi
Top achievements
Rank 1
Al Safavi asked on 22 Aug 2008, 10:27 PM

Hi,
I use the following code to retrieve data from RadGrid's cells:

Dim i as integer = 1  
Dim CellValue as New String 
CellValue = RadGrid1.MasterTableView.Items(i).Item("ColumnUniqueName").Text 

It works well as long as the column type is GridBoundColumn.  But, when convert the column to GridTemplateColumn the above code returns blank value.
How can I retrieve data from a RadGrid when the RadGrid's column is a GridTemplateColumn?

Thanks,
Al

4 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 25 Aug 2008, 06:27 AM
Hi Al,

When a TableCell have controls Text property will be empty string. You need to get reference to the control in the cell. Here is an example for TextBox:

CellValue = CType(RadGrid1.Items(i).Item("ColumnUniqueName").Controls(0), TextBox).Text

or you can use FindControl() method to find the control by ID:

CellValue = CType(RadGrid1.Items(i).FindControl("YourControlID"), TextBox).Text

Greetings,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Al Safavi
Top achievements
Rank 1
answered on 25 Aug 2008, 03:59 PM
Hi Vlad,
Thanks alot for your help.

Regards,
Al
0
Chom
Top achievements
Rank 1
answered on 23 Feb 2010, 01:05 AM
Hi Vlad

I have the same problem except I have a label in a template column in a radgrid. Where would I put this code to access the label? Can I access the label from the radgrids item command like so:

 

Select Case e.CommandName

 

 

Case "InsertNewRecord"

 

 

'Insert a new row into the BusinessListings table

 

dsSlides.InsertParameters(

"CustomerID").DefaultValue = Me.CustomerID

 



Thanks
Chommy
0
Princy
Top achievements
Rank 1
answered on 23 Feb 2010, 06:13 AM
Hi,

Please  have a  look at the link below:

Hope you find this link helpful.

Thanks,
Princy
Tags
Grid
Asked by
Al Safavi
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Al Safavi
Top achievements
Rank 1
Chom
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Share this question
or