?
Solved

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

Posted on 2008-10-29
2
Medium Priority
?
317 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 1000 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

Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

765 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