| | |
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 |
.net 2.0 activexcontrol ajax alltypeofvideos appliances application asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox commonfunctions control dataaccesslayer database datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose feedback fileuploader fill findcontrol flash form formatdecimal formview gridview gudi iis image javascript listbox login microsoft mobile mono mouse mssql news novell numerical opera panelmasterpagebuttoncontrols parent radio redirect registration relationaldatabases reportemail save schoolproject search security select sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos view vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers






