The issue I'm having is getting my DataTable to display in the Gridview. I have searched the web for answers, but everything I have found relates to binding database information right after a query is executed. I have to manipulate the data that I get from the query to display an average so everything in my datatable is stored in local variables and containers. Here is the code for the gridview on the aspx page and the block that is adding my rows to the table and binding the table to the girdview. any help on why it isn't displaying on the web would be appreciated. I'm using VS2012 and .Net v4
DataRow newRow;
for (int i = 0; i < portcount; i++)
{
newRow = averageTable.NewRow();
newRow["port_num"] = i+1;
newRow["port_status"] = currentstat[i]; //this is a list<Int32>
newRow["average_uptime"] = (statusCalc[i] / counter) * 100;
//statusCalc is an int array
averageTable.Rows.Add(newRow);
}
statusRdr.Close();
GridView completeView = new GridView();
this.completeView.Visible = true;
completeView.DataSource = averageTable;
completeView.DataBind();
<asp:Content ID="bodyContnet" ContentPlaceHolderID="cphContent" runat="server">
<asp:GridView ID="completeView" runat="server" AutoGenerateColumns="False" ViewStateMode="Enabled" ForeColor="WhiteSmoke" Width="51%" Height="204px">
<Columns>
<asp:BoundField DataField="port_num" HeaderText="Port" />
<asp:BoundField DataField="port_status" HeaderText="Status" />
<asp:BoundField DataField="average_uptime" HeaderText="Average Uptime" />
</Columns>
</asp:GridView>
<br />
<br />
<asp:Label ID="message" runat="server" ForeColor="WhiteSmoke" Text="Port Status Table"></asp:Label>
</asp:Content>