我正在尝试从列表中设置网格标题值得到错误
你调用的对象是空的
我先检查它,但我将列表值转换为字符串,在调试时我可以在列表中找到值
代码如下,
List<string> rows = new List<string>(
new string[] { "Item", "Quantity", "Price" });
GdItemList.HeaderRow.Cells[0].Text = Convert.ToString(rows[0]);
GdItemList.HeaderRow.Cells[1].Text = rows[1].ToString();
GdItemList.HeaderRow.Cells[2].Text = rows[2].ToString();
GdItemList 网格视图就像,
<asp:GridView ID="GdItemList" runat="server" ShowHeaderWhenEmpty="True" CellPadding="4"
EmptyDataText="No Record Found" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>