如何根据条件动态添加一些列的GridView?
<asp:gridview id="CustomersGridView" datasourceid="CustomersSource" autogeneratecolumns="true" emptydatatext="No data available." runat="server"> <columns> <asp:boundfield datafield="CustomerID" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" headertext="Company Name"/> <asp:boundfield datafield="Address" headertext="Address"/> <asp:boundfield datafield="City" headertext="City"/> <asp:boundfield datafield="PostalCode" headertext="Postal Code"/> <asp:boundfield datafield="Country" headertext="Country"/> </columns> for(int i; i < length; i++) <asp:boundfield datafield="text" headertext="text"/> </asp:gridview>
解决方法
试试这个:
BoundField test = new BoundField(); test.DataField = "New DATAfield Name"; test.Headertext = "New Header"; CustomersGridView.Columns.Add(test);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。