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