如何获取GridView 绑定数据库字段的名称即DataField
GridView 前台
<asp:BoundField DataField="CliNature" HeaderText="企业性质" >
<ItemStyle Width="60px" />
</asp:BoundField>
后面绑定DataTable后 我想在获取绑定字段的名称
比如第一列 绑定字段为CliNature,后台怎么才能获取到?
------解决方案--------------------------------------------------------
这个是设计时属性,获取不到的.
------解决方案--------------------------------------------------------
- HTML code
<asp:TemplateField HeaderText="aa"> <ItemTemplate> <asp:Label ID="aa" runat="server" Width="50px" Text='<%#Bind("aa") %>'></asp:Label> </ItemTemplate> </asp:TemplateField>
------解决方案--------------------------------------------------------
可以获取到的,那个gridview不是有索引和主键不?
你可以通过这两种方式中的一种就可以拿到了
好像是这样grivew.rows[当前行的索引].cell[你要拿的列的索引]