473,785 Members | 2,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

More GridView Problems

I wanted better control over the display of the command buttons, so I
created Template columns for each command. (Otherwise the GridView was
putting extras spacing around the images and such.)

Is there a way to tell the GridView to only show certain columns if that
particular row is in edit mode? I can hide the Edit and Delete buttons when
entering edit mode, but when I display save and cancel buttons by enabling
their rowns, not surprisingly, I get save and cancel buttons on every row.

Thanks.

Jerry
Mar 8 '06 #1
4 2069
Create an edit template.
<rl*****@newsgr oups.nospam> wrote in message
news:OS******** *****@TK2MSFTNG P15.phx.gbl...
I wanted better control over the display of the command buttons, so I
created Template columns for each command. (Otherwise the GridView was
putting extras spacing around the images and such.)

Is there a way to tell the GridView to only show certain columns if that
particular row is in edit mode? I can hide the Edit and Delete buttons
when entering edit mode, but when I display save and cancel buttons by
enabling their rowns, not surprisingly, I get save and cancel buttons on
every row.

Thanks.

Jerry

Mar 8 '06 #2
Hi Jerry,

I think Brooke's suggestion is reasonable. For GridView or other template
databound control(DataGri d...), it's hard and not efficient to show/hide a
whole column. However, we can easily show/hide the sub webcontrols in the
GridView's certain column's Template(ItemTe mlate or EditTemplate) according
to the databound value. So for your scenario, you can add a TemplateField
in the GridView and put the button and set them as visible in ItemTemplate
, but do not add the button or set them as invisible in EditTemplate. In
addition, if you need further customziation according to the databound at
runtime, you can register the gridview's RowDataBound event and perform
customization on the TemplateFields' s control collection.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 9 '06 #3
If I understand what you're saying, then this still doesn't have the effect
that I need, although I did just learn something new about the templates,
etc. as a side effect to investigating what you said...

The issue now is that when there is a row in edit mode, the other items
still have their item template buttons showing. I don't want the user to be
able to click an edit button for row 5 when they are already in edit mode
for row 3. That's why I was hiding columns. So that all of the rows had
the edit buttons hidden when the user is in edit mode for a single row.
(The only row that should have any buttons is the row being edited.

Am I missing something that makes that easy without hiding columns? Thanks.

Jerry
"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
news:q8******** ******@TK2MSFTN GXA03.phx.gbl.. .
Hi Jerry,

I think Brooke's suggestion is reasonable. For GridView or other template
databound control(DataGri d...), it's hard and not efficient to show/hide a
whole column. However, we can easily show/hide the sub webcontrols in the
GridView's certain column's Template(ItemTe mlate or EditTemplate)
according
to the databound value. So for your scenario, you can add a TemplateField
in the GridView and put the button and set them as visible in ItemTemplate
, but do not add the button or set them as invisible in EditTemplate. In
addition, if you need further customziation according to the databound at
runtime, you can register the gridview's RowDataBound event and perform
customization on the TemplateFields' s control collection.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 24 '06 #4
Thanks for your further followup Jerry,

So what you want is make some certain button in the ItemTemplate not
visible or usable when there is a certain item in edit mode, correct? If
so, I'm afraid you have to use the GridView control's RowDataBound or
RowCreated event, in that event, you can get the reference to the certain
control (button ) you want to disable, and whether to disable it depend on
the current GridView's EditItemIndex, if it is in the valid range(that
means there is a certain item in edit mode), you will need to disable that
control in each item template row. How do you think of this?

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Mar 28 '06 #5

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

Similar topics

2
2160
by: tacmec | last post by:
ASP.NET 2.0 (C#) application. I have a web form with a GridView, which is populated dynamically. See the code below. First time to the page, IsPostBack is false. Therefore, DisplayItems() is called and the GridView is populated. No problems. When I click the select button in the GridView, I first go to Page_Load and IsPostBack = true. Therefore, DisplayItems() is not called again. No problems. Then the...
1
3250
by: Giovanni | last post by:
Dear Friends/Gurus, I have exhausted myself and have yet no solution to the following: I have an ASP.NET 2.0 Survey type application. On a page, I have placed a GridView which is bound to an SQLDataSource. The GridView contains 3 columns: QuestionNumber, QuestionText, and a TemplateField. Each row in the GridView represents a question in a table (Ex.: "18. Satisfaction Level").
2
3472
by: loga123 | last post by:
Hi All, I am using Link Button for DELETE on the gridview. When I click on DELETE link, I get the ArgumentOutOfRangeException. But...it deletes the record from table in the database. On Gridview_rowdatabound, I am dynamically building hyperlink control based on the values in the other fields. Here is my code for Gridview_rowdatabound. It does work sometimes though.
0
1234
by: JMax | last post by:
Hello! I have a GridView that has another GridView embedded in it. The embedded GridView has some complex editing features (requiring JavaScript duplicating drop down lists), so I have to use the OnUpdating event in the embedded GridView. The problem occurs when I am in the OnUpdating event. Right now, there are two rows where the GridView controls are embedded. When I update the upper embedded GridView’s data, the event fires, after...
3
4605
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a datasource to this GridView in runtime. But I cannot
8
18090
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to display data in a "GridView" which is tied to an "ObjectDataSource". In turn, this ObjectDatasource gets it's data from a strongly-typed business object within my code.
1
2813
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I have a GridView that I dynamically add columns to in code. The way that my code is written, everything works properly if I use GridView.Columns.Add to simply add the columns to the end of the collection. However, if I use GridView.Columns.Insert to inject the columns in the middle of the existing columns, I see lots of exceptions when I page the GridView, because certain controls contained within the grid are mysteriously absent? Can...
6
1986
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview control with a template column that has a textbox and when the control is bound to the datasource the textbox is filled ok. I then change what is in the textbox in the gridview control and in the gridview_RowDataBound event I have string DiscDescrip = Convert.ToString((e.Row.Cells.FindControl("txbxDiscgv") as TextBox ).Text); This returns what was initially loaded in the textbox but not what I had just changed it...
1
7261
by: Dave | last post by:
I'm having problems getting the GridView to reliably display a large amount of data (50,000+ rows). I am working my way through the excellent book “Real World ASP.NET Best Practices” by Farhan Muhammad. In some cases I’m trying to extend the examples. Currently, I have the following code to read data from a SQL Server 2005 database and display in a GridView:
0
10330
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.