-----------------------------------------------------------
New Message on MumbaiUserGroup
-----------------------------------------------------------
From: Swapnil_B1
Message 1 in Discussion
Folks,<o:p></o:p>
<o:p></o:p>
I have got most of the queries on how do we hide the columns in GridView
control in ASP.NET 2.0. <o:p></o:p>
<o:p> </o:p>
When displaying data in a grid, there are instances when you would want the
data column not to be visible to the client and still require it for further
processing. This can be achieved by simply setting the columns visibility
property to False. This can be done in versions prior to ASP.NET 2.0, but how
do you achieve this in ASP.NET 2.0? <o:p></o:p>
<o:p> </o:p>
The GridView of ASP.NET 2.0 has replaced the DataGrid and the scenario
mentioned above just does not work in ASP.NET 2.0. <o:p></o:p>
<o:p> </o:p>
When the columns visibility property is set to False, the GridView does not
bind the data to the column. When you try to retrieve data from the hidden
column, you get an empty string. <o:p></o:p>
Result? You start debugging your application and end up being lost in the web.
<o:p></o:p>
I hope the solution mentioned below saves some of your precious development
time. <o:p></o:p>
Add the GridViews RowCreated event and set the cells visibility property to
False. <o:p></o:p>
<o:p> </o:p>
Public Sub myGridView_OnRowCreated(ByVal sender As Object, ByVal e As
_<o:p></o:p>
Web.UI.WebControls.GridViewRowEventArgs) Handles
myGridView.RowCreated<o:p></o:p>
'Hide the cell of the column you do not want to display as each row
gets<o:p></o:p>
'created, eventually leading to the entire column being hidden.<o:p></o:p>
e.Row.Cells(0).Visible = False<o:p></o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
The GridViews RowCreated event gets called after the data is bound to the
grid. So the first column is hidden only after it is databound. It is
possible to hide the other columns by changing the cell index. <o:p></o:p>
<o:p> </o:p>
Hope this is useful to you. <o:p></o:p>
<o:p> </o:p>
Swapnil (Swaps) <o:p></o:p>
http://swapsnet.spaces.live.com/ <o:p></o:p>
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]