Solved

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# DataTable (in memory) vs SQL Lookups 4 68
C#:  Need to switch between timer loop and token driven loop 2 30
Datagridview column resizing 8 25
Example code 13 42
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 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