473,414 Members | 1,776 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,414 software developers and data experts.

How to hide a GridView column when the column's Visible property does not support databinding?

I need to hide a GridView's "edit" column if the user's role does not
support editing. However, the column's Visible property does not support
databinding. Is there a workaround?

Thanks,

Keith
Oct 26 '06 #1
2 18870
hejdig.

myGrid.Columns[ x ].Visible = ( NotSupportEditing == myUser.Role );

HTH

/OF

----------
I need to hide a GridView's "edit" column if the user's role does not
support editing. However, the column's Visible property does not support
databinding. Is there a workaround?

Oct 26 '06 #2
Hi

if u set the visiblity of a column false then it cant be bind. The
solution to this problem is

i hope u dont mind the code is in vb.net if u ve any problem. then ask
me i will help u in converting this code to c# .
1. create a RowCreated event handler for that datagrid or gridview and
then pass the no of that column you want to hide. and if hide.

what happening here is: if u set the visiblity to false b4 data binding
then cloumn will not be created. and rowcreated event fired after
RowDataBound event fired. so here u r fee to hide that column.

Protected Sub grdMaster_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
grdMaster.RowCreated

e.Row.Cells(0).Visible = False
e.Row.Cells(1).Visible = False

End Sub

i hope it will be helpful for u

Keithb wrote:
I need to hide a GridView's "edit" column if the user's role does not
support editing. However, the column's Visible property does not support
databinding. Is there a workaround?

Thanks,

Keith
Oct 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Marc Robitaille | last post by:
Hello, Hello, I developed a UserControl. It has funny behavior. It is composed of three controls. A texbox, a combobox and a button. There are three properties to indicate the visibility of...
1
by: Eric | last post by:
I have a GridView control that I want to sort on multiple columns when I click a particular column. For example, I display Last name + ", " + First name in the first column and display id in the...
1
by: shema | last post by:
Hi, I'm working in visual studio 2005 on web site application and my database is microsoft sql server 2005. I need to update my GridView while one column has property "visible" set to...
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
4
by: SEliel | last post by:
Hello everyone: I'm programming a custom GridView, adding column by column dynamically. Every column is a TemplateField, and I've made a class hierarchy for each template (TextColumnTemplate,...
5
by: Doogie | last post by:
Hi, I am trying to access the visible property of an ASP button inside javascript to no avail. Here's what my button control looks like: <asp:Button id="btnAcceptTrips" name="btnAcceptTrips"...
8
by: Doc John | last post by:
I have an MDI container with a child Form which will be visible according to certain events. The problem is that when I set the property Visible to False and then back to True, the Form will be in...
5
by: =?Utf-8?B?VGVycnk=?= | last post by:
Hi, I have a couple of labels on a form and their visible property is bound to boolean properties on a custom object. When I first load the form, all works as it should. This form is 'tied'...
4
by: Rick Beach | last post by:
The below programming works properly to show and hide gridviews: <script type="text/javascript"> function hideGrid() {document.getElementById("Gridview3").style.displa y = "none";} function...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.