| | |
If Datasource=null, how to show gridview with header
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 104
Reputation:
Solved Threads: 18
Before binding your DataTable(DataSource) to the grid, check the row count of the DataTable. If its empty (row count = 0) then add a dummy row to the DataTable and then bind it with the grid. Also make the visibility of the dummy row in the grid to false.
Here is some sample code
Here is some sample code
ASP.NET Syntax (Toggle Plain Text)
if(dt.Rows.Count > 0 ) { //DataSource is not empty gvResults.DataSource = dt; gvResults.DataBind(); } else { //DataSource empty, add dummy row dt.Rows.Add(dt.NewRow()); gvResults.DataSource = dt; gvResults.DataBind(); //Make dummy row invisible gvResults.Rows[0].Visible = false; }
Falling down is not defeat...
Defeat is when you refuse to getup...
Defeat is when you refuse to getup...
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Problem in updating date field in a table row
- Next Thread: need a code to open a exe file in asp
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax alltypeofvideos anathor appliances application asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions control countryselector dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash folder form gridview gudi iis image javascript list listbox login maps microsoft mobile mouse mssql nameisnotdeclared news novell numerical opera panelmasterpagebuttoncontrols parent problem project radio redirect registration relationaldatabases reportemail richtextbox schoolproject search security select sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visualstudio vs2008 web webapplications webdevelopment webprogramming webservice wizard xsl






