在C#中,BoundField類是GridView控件中的一個(gè)列類型,用于顯示綁定到數(shù)據(jù)源的字段的值。下面是BoundField類的使用方法:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
</asp:GridView>
BoundField field = new BoundField();
field.DataField = "FieldName";
field.HeaderText = "Field Header";
field.ItemStyle.CssClass = "field-cell";
GridView1.Columns.Add(field);
GridView1.DataSource = yourDataSource;
GridView1.DataBind();
通過(guò)以上步驟,BoundField將會(huì)在GridView中顯示綁定到數(shù)據(jù)源的字段的值。