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

Add control to cell on dynamic grid

3 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 22 May 2008, 02:00 PM
I am writing out a grid dynamically and I need to add a control to a specific cell. I am able to get the cell I need but the control does not appear in the cell.

TRC(

"TRC").Controls.Add(AddTRCLink(TRC.Cells(x).Text, Session("IDforAcc")))

For example or

TRC.Cells(x).Controls.Add(AddTRCLink(TRC.Cells(x).Text, Session("IDforAcc")))

the AddTRCLink fucntion returns a placeholder that has vavious other contols in it.  this works fine using the default gridview.

Also I am unble to even set the text property as a simple test.

Any Ideas?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 May 2008, 04:00 AM
Hi Randy,

Try accessing the Grid cell using its Column UniqueName property and try to add controls as shown below.

CS:
 protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
     { 
 
         if (e.Item is GridDataItem) 
         { 
             GridDataItem item = (GridDataItem)e.Item; 
             Label lbl = new Label(); 
             lbl.ID = "newlbl"
             lbl.Text = "HELLO"
             item["columnUniqueName"].Controls.Add(lbl); 
         } 
    } 


Thanks
Shinu.
0
Atiq Ur Rehman
Top achievements
Rank 1
answered on 15 Aug 2008, 02:30 PM
hi I am doing it exactly same way by itemdatabound but its not working for me. It doesn't show on the grid, just a blank row.
can you please help me out as well?
Thanks 
Atiq    
0
Missing User
answered on 15 Aug 2008, 02:50 PM
Hello Atiq,


Please find attached a sample web application that demonstrates the needed approach.


Regards,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Randy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Atiq Ur Rehman
Top achievements
Rank 1
Missing User
Share this question
or