Display only Columns that have Data in GridView Control

Good evening to the community, thanks for the help that ever provide

The situation is the following:

I'm working in a application that have like 50 columns in the Database that represents Earning Codes for employees, but most of the times only 10 are used.

What if something can be done to only display in the GridView Control the columns that the value is different than Null.

 
Thanks for any leadSmile

evick

 

0
evick
10/23/2008 10:49:26 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
767 Views

Similar Articles

[PageSpeed] 11
Get it on Google Play
Get it on Apple App Store

 If you set the gridview to auto create the columns based on the datasource then when selecting data from the db only return the columns that have data in them.

aspro


Please mark your posts as answered and thank the asp gods of the forum
0
aspro
10/24/2008 12:01:33 AM
Just databind the visible attribute of the column value to an expression that evaluates to true when the field is non-empty, something like

Visible='<%# ((string)Eval("ColumnName")) != "" %>'


My Blog


"Don't be afraid to be wrong; otherwise you'll never be right."
0
budugu
10/24/2008 2:22:15 AM

Thanks to everybody for the answers , by this way is working

But just to do it better in what way can check the same condition to a range of columns I use (1 - 9) bu doesn't like it

Thanks for the help  

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 

For Each gvr As GridViewRow In GridView1.Rows
            If gvr.Cells(9).Text = "Null" Then
                GridView1.HeaderRow.Cells(9).Visible = False
                gvr.Cells(9).Visible = False
            Else
                GridView1.HeaderRow.Cells(9).Visible = True
                gvr.Cells(9).Visible = True

            End If
End Sub
 
0
evick
10/24/2008 2:29:08 PM
Reply:

Similar Artilces:

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

Bind Data to an Image Control not in a Data Presentation Control
I've been searching for two days but I don't really know what to search for.I'm making a site for a photographer.  The Default.aspx page displays Albums by showing a title, image and description from the database table Albums. Click an album to view the contents and it passes the QueryString which is AlbumName.  The ViewAlbum.aspx page uses the QueryString to display an UpdatePanel holding a Large Image and a Repeater full of dynamically filled ImageButtons for thumbs.  Both are from the database table Photos and are retrieved using an ObjectDataSource. Click the ...

i have work on gridview control.in that i have 3columns.name as subject,bookname,link. in this some link column data are very large.according to that data(no spaces in that data)gridview has changed.i
hi,i have work on gridview control.in that i have 3columns.name as subject,bookname,link. in this some link column data are very large.according to that data(no spaces in that data)gridview has changed.i want display half of the data and remaining display like this.(ex:http://ww.yahoo.com...........).how can i display like this,and one more thing is always the column size will constant. Try something like this: <asp:templatefield headertext="Link"> <itemtemplate> <asp:hyperlink id="HyperLink1" runat="server" navigateurl='<...

Update other controls after a Postback has fired from another control - eg insert data
Hi This is a slight modification to the personalweb asp.net template which shipped with VS2005 I have a web form - linked to a master with two content placeholders left and right: #1 In the left i have a formview containing a textbox + button - and a datasrouce object with an insertmethod - this calls a method to insert the textbox data into table albums: #2 In the right  i have a gridview which has a datasource this has a selectmethod which calls a select method from table albums. Because i am using a maser template with two content placeholders i cannot use the same ObjectD...

Trying to use the FAQ " Sorting and paging in the GridView control when not using data source controls "Sorting and paging in the GridView control when not using..."
and I am not getting the results I had hoped for.  I keep getting a "Compiler Error Message: CS0123: No overload for 'AdhocJobGridView_PageIndexChanged' matches delegate 'System.EventHandler'".   Here is my event handling... protected void AdhocJobGridView_PageIndexChanged(object sender, GridViewPageEventArgs e){ try { AdhocJobGridView.DataSource = wsBaseInfoArray; AdhocJobGridView.PageIndex = e.NewPageIndex; AdhocJobGridView.DataBind(); }catch (Exception ex) {throw ex; }   Here is my aspx... <asp:GridView ID="AdhocJobGridView...

No Control over Grid or Column Widths in a GridView with displaying XML data
No matter which properties I try to adjust, my gridview extends well past  the page width boundary of 988px, I am trying to set. My application is reporting on changes made to an Access DB which I am storing in an XML file. There are 8 columns in my Grid but the ones that, my guess, could be causing the problem are OldValues and NewValues. I am not parsing the data in these columns because there are many tables involved and I just want to have a simple audit trail of what changes were made to any of the tables. Obviously, these two columns are variable in length  and in some c...

ajax control in data presentation controls
can i add ajax controls (MaskedEdit) to presentation controls (dataGrid, dataForm)?? Hi,of course. But keep in mind that those controls are extenders, so you append them to an existing control. Just convert your GridView / DetailsView-fields into templated fields and add the extender you'd like to use to the controls.RegardsMarco Buerckel Don't forget to mark posts that were helpful as answers. Actually, if you looked at the source code for the Masked Edit Extender, you'd see  [TargetControlType(typeof(TextBox))]Meaning, targeting any control type other than textboxes...

Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once?
 Hi Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once onto the grid? What I mean is some grid that 's as flexible as MS Excel grid for example.  Any suggestions will be very much appreciated.E The Repeater control is a highly customisable data presentation controlRohin.NET developerNever trust a computer you can't throw out a window. - Steve WozniakPlease remember to click on 'Mark as answer', if this post helped you......

data presentation controls (how to call the individual controls)
Hi please help me.,i have this question., example i create a site with one control, like textbox. when i double click on the white page, the page load event, in the intellisense, the textbox is visible, but when a formview with a textbox inside, in the same page load event, intellisense, the textbox is not available. how can i do the simple intellisense calling where the textbox is just outside a data presentation control like formview. i mean by this intellisense calling is in VB code view., thanks JFRBPH12™  The textbox is within the formview then you can find it like this...

How can I control the width of a column in the GridView control.
From searching I see mention of ways to do it before the controls are bound. Is there a simpler way? If not, could someone explain to me how I need to go about it?Here is the code: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"        DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."        OnSelectedIndexChanged="GridView1_SelectedIndexChanged">   &nbs...

Menu control is displaying behind Gridview control
I have placed a menu control just above the gridview control but when i click the menu control it displaysome of the menu options and rest of the menu options display behind the gridview.Is there anyway any option which make the menu to display over gridview.Mark as answer if anybody's post has helped you Typically the ZIndex will control that: http://www.w3schools.com/Css/pr_pos_z-index.aspDavid Kiffhttp://DavidKiff.co.uk-- "Mark As Answer" If my reply helped you --...

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one colum.now my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the data.now my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

-- Need to Display data in two GridView controls, but second one could not be displayed?
Dear all, I wrote a code segment to display data in two GridView controls one by one as below. The first one is displayed ok. But, the second one is not displayed. Did I miss anything?         ads.DataFile = "~/App_Data/color_match_live.mdb"                ads.SelectCommand = "SELECT COUNT(*) FROM [tech_mstr] WHERE [month] = ?"        ads.SelectParameters.Add("month", sel_month)        Di...

Display data in GridView Control
How can I group the same data in a field inside a gridview. The data is in a table on the db. Ex: Customers, Orders I dont wanto to display the same customer more than one time Customer1 - Order1, Order2, Order3.... Customer2 - Order1, Order2, Order3..... Can this be posible using a gridview?   use a nested gridview inside an itemtemplate where can I find a example for this? Thanks Are you binding to a SQL DataSource? If you were then it'd be a matter of using "Group By..." in your query to get rid of those duplicates.This is the part where I ...

Web resources about - Display only Columns that have Data in GridView Control - asp.net.presentation-controls

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012

DotNetKicks.com - Upcoming stories
DotNetKicks.com is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 2/2/2016 9:09:38 PM