2017-01-23 62 views
0

我的網格視圖數據綁定就像這樣:如何才能找到ItemTemplate中的值,而不coutrol綁定

<asp:TemplateField HeaderText="COMPANY NAME"> 
    <ItemTemplate> 
    <%#DataBinder.Eval(Container.DataItem, "Company_Name")%> 
    </ItemTemplate> 
</asp:TemplateField> 
+0

你想在代碼中獲得價值的背後? –

+0

請查看http://stackoverflow.com/help/mcve以瞭解如何創建最小,完整和可驗證的示例 – pringi

回答

0

你需要投控制DataBoundLiteralControl,如:

foreach (GridViewRow item in GridView1.Rows) 
     var yourValue = (item.Cells[0].Controls[0] as DataBoundLiteralControl).Text; 
相關問題