473,387 Members | 3,801 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,387 software developers and data experts.

Grid View Display different columns between item/edit templates

Hi,

In a gridview, How can i display different columns between item and edit
modes.
For eg. i have a sql that returns productname, categoryname, etc.
In viewmode, i need to display only productname column and not categoryname
column. Again in Edit mode, i need display/edit category name only. But not
productname column shouldnt be displayed/editable.

In visual studio 2005, I tried converting the columns to template fields and
removed the field label/textboxes in item and edit templates.
But the column exits with the header.

How can i show/hide differnt columns between view/edit modes?
can it be done using visual studio 2005 designer mode?

Any help appreciated.

Thanks
Gane
Feb 16 '07 #1
2 7204
I figured out by setting visible false for the field in GridView1_RowEditing
method.

Thanks

"gane" wrote:
Hi,

In a gridview, How can i display different columns between item and edit
modes.
For eg. i have a sql that returns productname, categoryname, etc.
In viewmode, i need to display only productname column and not categoryname
column. Again in Edit mode, i need display/edit category name only. But not
productname column shouldnt be displayed/editable.

In visual studio 2005, I tried converting the columns to template fields and
removed the field label/textboxes in item and edit templates.
But the column exits with the header.

How can i show/hide differnt columns between view/edit modes?
can it be done using visual studio 2005 designer mode?

Any help appreciated.

Thanks
Gane
Feb 16 '07 #2
No, you can't do that from Designer mode, designer mode has only the simple
tasks, for what you want to accomplish you need to use the code mode.

create an event onRowDataBound for that GridView

now all you need to do is Hide the cells number that you want

[let's imagine that you have 3 rows, and for normal view you need the 1st
and the 2nd to show, to edit you need the 1st and the 3rd]

Protected Sub gv_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv.RowDataBound
If e.Row.RowState = DataControlRowState.Normal Or e.Row.RowState =
DataControlRowState.Alternate Then
e.Row.Cells(0).Visible = True
e.Row.Cells(1).Visible = True
e.Row.Cells(2).Visible = False
ElseIf e.Row.RowState = DataControlRowState.Normal Then
e.Row.Cells(0).Visible = True
e.Row.Cells(1).Visible = False
e.Row.Cells(2).Visible = True
End If
End Sub

and that's it. easy right?
--

Bruno Alexandre
Strøby, Danmark

"a Portuguese in Denmark"
"gane" <ga**@discussions.microsoft.comwrote in message
news:CA**********************************@microsof t.com...
Hi,

In a gridview, How can i display different columns between item and edit
modes.
For eg. i have a sql that returns productname, categoryname, etc.
In viewmode, i need to display only productname column and not
categoryname
column. Again in Edit mode, i need display/edit category name only. But
not
productname column shouldnt be displayed/editable.

In visual studio 2005, I tried converting the columns to template fields
and
removed the field label/textboxes in item and edit templates.
But the column exits with the header.

How can i show/hide differnt columns between view/edit modes?
can it be done using visual studio 2005 designer mode?

Any help appreciated.

Thanks
Gane

Feb 16 '07 #3

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

Similar topics

4
by: Filippo Pandiani | last post by:
I have a grid that shows the file list from a folder. On the postback, how do I get a Dataset from this grid? Thanks, Filippo.
3
by: Simon Harris | last post by:
Hi All, I have a data grid which displays country names. I now wish to display the country flag images above the names. Can someone please advise how I display an image in a datagrid? I have a...
4
by: Bazza Formez | last post by:
Hi there, What determines the sizes of rows / columns / cells when a grid is in edit mode ? When I click the edit command of a row item, the whole grid 'bounces' to a much larger size... and...
3
by: Kenneth P | last post by:
Hi, I've planned an app where there's a lot of columns in a table and because of that I'd like to split up the columns when presenting them in a datagrid. I'll give you an example. It's always...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
2
by: Joe Griffith | last post by:
I'm using a Win Forms Data Grid View control in unbound mode. When I add columns using the wizard the first item is the column name. Everything works fine. However, if you return to the...
117
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of...
2
by: Valli | last post by:
Hi, I am using a gridview to display data from table. In the gridview, there are 5 columns in which one column contains link name(eg. http://www.msn.com). I want to show this link as an...
1
by: rogerford | last post by:
I have a grid which i bind with values from Database. I have events to edit and update the grid. I am not using SqlDatasource to connect to DB. Rather i am doing the updating of the grid...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.