Met a very strange question,
I use the SQL statement, first to some form of data filtering and statistics and calculation, such as the sales statistics in January to December and total quantity, generate a dataTable, the data is filled into the GridView (as a dataSource), shows that there is no problem, everything is normal,
But when I use the code to set the column width, or want to set the display decimal places of two, system has been an error, according to the index value out of range, such as
Gv2. Columns [1]. ItemStyle. Width=200 error,
I calculated by the following method to the total number of columns, I found is 0, that is not generated data,
Int j=DGV Columns. The Count;
Response. Write (j.t. oString ());
But from the page to view the source code, there are over ten columns show the td,
VS again watch the code, reference not filtered before calculation data, automatically display similar & lt; ItemTemplate> The code, but this time no, there is only one & lt; Asp: the GridView ID="GridView1" runat="server" AutoGenerateColumns="true" & gt; ,
Don't wonder, the Gridview data after loading operations will default to is a null value?