Solved

I want dropdownlist to appear in gridview ONLY when in edit mode

Posted on 2008-10-29
2
312 Views
Last Modified: 2013-11-26
I have a working, editable gridview. One of the columns in my gridview is employeeID, which is represented by a dropdownlist control (DataTextField="employeeName", DataValueField="employeeID"). Another column is an "edit" link.

So when I load the page, I see my gridview with all 10 records. Each of the 10 records has its own "edit" link. Each of the 10 records also has its own "employeeID" dropdownlist column.

When I click "edit" for one of the records and make a change in its "employeeID" dropdown menu, then click "update", my changes show up fine in my gridview. So the general plumbing works.

My question is this: Is it possible to show the dropdownlist control ONLY for the active record (i.e. when the user has clicked "edit" for a particular record), instead of showing the dropdownlist control for ALL records when just in view mode (vs. edit mode). It just seems pointless to have all those dropdownmenus populated when I could just display the employee name (for all but the selected/active record) as a label when in view mode.

I'm particularly interested in whether there is a "no-code-necessary" way of doing this in Visual Studio 2005.

Thanks!
0
Comment
Question by:reallyv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
imateyelectronics earned 250 total points
ID: 22837785
If I am understanding you correctly you want to be able to show the drop down list only when editing a single item within the gridview edit mode.  For this purpose you didn't really need an Editable gridview at all.  You could have simple just edited the item templates of your columns, while dragging the drop down list within the edit template view.

For simplicity state I'll show you an example with a gridview named gridview1 and a single column named Testfield.  The testfield column is a gridview templatefield.  I simply dragged a label within the item template and a dropdownlist within the edit template.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
            <Columns>
                <asp:TemplateField HeaderText="TestField">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server">
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

Open in new window

0
 

Author Comment

by:reallyv
ID: 22845650
What a revelation! Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question