Forum

asp.net mvc sorgu s...
 
Bildirimler
Hepsini Temizle

asp.net mvc sorgu sonucu kolon adlarını hakkında

2 Yazılar
2 Üyeler
0 Reactions
888 Görüntüleme
(@sinemerkan)
Gönderiler: 234
Reputable Member
Konu başlatıcı
 

arkadaşlar iyi günler ,mvc de kolon adlarını manuel yazmak yerine sorgudan nasıl okutabiliyoruz

<th>Malzeme Kodu</>

<th>Malzeme Adı</>

gibi mauel yazmak yerine direk sorgudaki kolon adlarını kullanmak istiyorum.

 
Gönderildi : 19/03/2019 14:14

(@birolaydugan)
Gönderiler: 867
Prominent Member
 

aşağıdaki şekilde rahatlıklar yapabilirsiniz.

<table>
                            <thead>
                            <tr>                               
                               
                                @foreach (DataColumn col in Model.Columns)    
                                {         
                                    <th>@col.ColumnName</th>
                                }
                            </tr>
                            </thead>
                            <tbody>
                            @foreach (DataRow row in Model.Rows)    
                            {        
                                <tr>
                                    @foreach (DataColumn col in Model.Columns)        
                                    {             
                                        <td>@row[col.ColumnName]</td>
                                    }        
                                </tr>
                            }                            
                            </tbody>
                            <tfoot>
                            <tr>                              
                               
                                @foreach (DataColumn col in Model.Columns)    
                                {         
                                    <th>@col.ColumnName</th>
                                }
                            </tr>
                            </tfoot>
                        </table>

 

 
Gönderildi : 19/03/2019 15:29

Paylaş: