473,378 Members | 1,152 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,378 software developers and data experts.

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 2053
Create an edit template.
<rl*****@newsgroups.nospam> wrote in message
news:OS*************@TK2MSFTNGP15.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(DataGrid...), 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(ItemTemlate 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**************@TK2MSFTNGXA03.phx.gbl...
Hi Jerry,

I think Brooke's suggestion is reasonable. For GridView or other template
databound control(DataGrid...), 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(ItemTemlate 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
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...
1
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...
2
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...
0
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...
3
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...
8
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...
1
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...
6
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...
1
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.