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

[Solved] How to dynamically create Table in GridTemplateColumn's Header and ItemTemplate

1 Answer 241 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 09 Jul 2009, 07:45 AM
Hi All,

I have grid and using two GridTemplateColumn, Primary BIN and Secondary BIN. My grid format is as follow and I know exactly how many column in Primary and Secondary BIN. So I used static table in HeaderTemplate and ItemTempalte in GridTemplateColumn.

Primay BIN Secondary BIN
Visa Master Visa Master
USD 10 15 1 2
SGD 12 5 3 4
AUD 16 20 5 6

 

 

Now my requirement is changed. BIN Column (Card Type) may vary base on user input. Mean, sometime, Visa, Master, Dinner or Visa Master, AMEX in Primary BIN and Secondary BIN.

How can I dynamically create table in GridTemplateColumn.

Here is my current TemplateColumn.

 

<telerik:GridTemplateColumn UniqueName="TemplateColumnSourceBin"
                                      <HeaderTemplate> 
                                       <table id="Table1" cellspacing="0" cellpadding="0" style="width:550px;" class="myTable"
                                        <tr> 
                                         <td colspan="5" align="center"><b>Primary BIN</b></td
                                        </tr> 
                                        <tr> 
                                         <td style="width: 30%">Code</td> 
                                         <td style="width: 20%">Visa </td> 
                                         <td style="width: 20%">Master</td>                                          
                                        </tr> 
                                       </table> 
                                      </HeaderTemplate> 
                                      <ItemTemplate> 
                                       <table id="Table2" cellspacing="0" cellpadding="0" width="100%" border="0px" class="myTable"
                                        <tr> 
                                         <td style="width: 30%"><%# DataBinder.Eval(Container.DataItem, "Code"></td
                                         <td style="width: 20%"><%# DataBinder.Eval(Container.DataItem, "Visa")%></td
                                         <td style="width: 20%"><%# DataBinder.Eval(Container.DataItem, "Master")%></td>                                                        </tr> 
                                       </table> 
                                      </ItemTemplate> 
                                      <ItemStyle HorizontalAlign="Center" /> 
                                     </telerik:GridTemplateColumn> 

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Jul 2009, 11:01 AM
Hello Alex,

Check out the following forum link which discusses on a similar scenario as yours:
Adding Multiple Header Rows at Runtime in RadGrid

Hope this helps..
Princy.
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or