Solved

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

Posted on 2008-10-29
2
301 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

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…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now