473,322 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

gridview cantrol

Hi
I am using asp.net 2.0. Here I am binding gridview with selected column through dataset but here comming one problem. I am selecting fields clientid, client name, clientaddress but bind only clientname, clientaddress. but this prevent to load page but whenever I bind all selected coloumns then its shows records in gridview

Pls give detail if i want to select all coloumns but want to show only some selected coloumns

Thanks
anil kumar dwivedi
Jul 16 '07 #1
3 1332
nateraaaa
663 Expert 512MB
Hi
I am using asp.net 2.0. Here I am binding gridview with selected column through dataset but here comming one problem. I am selecting fields clientid, client name, clientaddress but bind only clientname, clientaddress. but this prevent to load page but whenever I bind all selected coloumns then its shows records in gridview

Pls give detail if i want to select all coloumns but want to show only some selected coloumns

Thanks
anil kumar dwivedi
You should be able to change the visibility property of the gridview column that you do not want to display to false.

Expand|Select|Wrap|Line Numbers
  1. gvGridView1.Columns[columnindex].Visible = false;
columnindex is zero based. If you have 3 columns and want to hide the last column columnindex will be 2 not 3.

Nathan
Jul 16 '07 #2
Plater
7,872 Expert 4TB
After you have bound your datasource to the Gridview you can process it.

There is a .Visible property on Columns:
mygridview.Columns[0].Visible

So you could try something like:
Expand|Select|Wrap|Line Numbers
  1. if (mygridview.HeaderRow != null)
  2. {
  3.    for (int i = 0; i < mygridview.HeaderRow.Cells.Count; i++)
  4.    {
  5.       if (mygridview.HeaderRow.Cells[i].Text == "ColumnToHide")
  6.       {
  7.          mygridview.Columns[i].Visible =false;
  8.       }
  9.    }
  10. }
  11.  
Jul 16 '07 #3
Thanks alot for feedback this one very helpful to me


Regards
Anil Kumar Dwivedi
Jul 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
6
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
6
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the...
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.