By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,375 Members | 1,390 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,375 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.