How can I show my controls even if my table columns are null using gridview? All I know is ShowHeaderWhenEmpty = "true"
If the gridview data source is NULL, you can create a temporary datatable and designate it as a gridview data source.
if (GridView1.DataSource == null) { DataTable dt = new DataTable(); dt.Columns.Add("Name"); DataRow dr = dt.NewRow(); dr[0] = ""; dt.Rows.Add(dr); GridView1.DataSource=dt; GridView1.DataBind(); }
If your data is NULL, then there is no data to display. To display controls, you need to have data. I would try to create a dummy string if db returns null.
if(db.rows.count < 1) { //add a row with dummy values }
, .
:
dataGridView1.Rows.Add(num_rows);
Source: https://habr.com/ru/post/1527843/More articles:Powershell: returns an error exit code if it does not match the string - powershellQT, когда пользователь простаивает с компьютера? - qtHow to remove space from pie chart in highchart.js? - javascriptGet a more detailed template in gcc or clang diagnostics - gccAccess to the server side with unambiguous configuration of cross-platform configuration - androidangularjs ie8 error: module not found in ie8, but working fine in ie9 - angularjsJava, relevant exceptions - javaCould not start repack in git gc - gitSymfony2 showing that "token was not found in SecurityContext" instead of my AuthenticationException - securityHow to change brackets to underline underline? - sublimetextAll Articles