Solved

Addiing a drop down list box in a DetailsView cotrol

Posted on 2008-09-30
8
1,081 Views
Last Modified: 2012-06-21
I cannot find any information in any of my books or online tutorials about adding changing a text field in a DetailsView to be a drop down list that is also bould to a code file in the database. What is a good source for information on this?
0
Comment
Question by:bfeddish
[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
  • 5
  • 3
8 Comments
 
LVL 18

Accepted Solution

by:
David Robitaille earned 500 total points
ID: 22606259
use a template field
http://www.asp.net/learn/data-access/tutorial-13-vb.aspx
and place your drop down list into that template
 
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22730343
it<s for a gridview, but it<s the same for a DetailsView
http://msdn.microsoft.com/en-ca/library/ms178294(vs.80).aspx
 
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22786270

Could i know, why does it get a "B", if it resolve the issue, I think I should get a "A".
Please read this:
http://www.experts-exchange.com/help.jsp#hi403 
abstract: "an answer is worth an A, unless it doesn't resolve your issue"
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 1

Author Comment

by:bfeddish
ID: 22786375
Correct, it did not complelty answer my question.  The data in the listbox needed to be bound to a table in the database. That tutorial did not mention it. To answer my own question, this is what I was looking for:

 <asp:TemplateField HeaderText="Vendor Type" SortExpression="VendorType">
                    <EditItemTemplate>
                        <asp:DropDownList ID="dd1" runat="server"                        
                        DataSourceID="dsVendorTypes"
                        DataTextField="Description" DataValueField="ID"
                        SelectedValue= '<%# Bind("VendorType") %>' />                        
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:DropDownList ID="dd1" runat="server"                        
                        DataSourceID="dsVendorTypes"
                        DataTextField="Description"
                        DataValueField="ID"
                        SelectedValue= '<%# Bind("VendorType") %>' />
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:DropDownList ID="dd1" runat="server"                        
                        DataSourceID="dsVendorTypes"
                        DataTextField="Description"
                        DataValueField="ID"
                        SelectedValue= '<%# Bind("VendorType") %>'
                        Enabled = "false"   />
                    </ItemTemplate>
                </asp:TemplateField>
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22786459
Thats why I send an second link.
Next time, if it dosen`t fulfill your need, please seen some feedback so experts could provide an more complete answer. Also, if you grade lower than "A", please provide some "Grading comments" that explain why.
It s not because I`m angry, I just want to know so I will be better next time...
 
0
 
LVL 1

Author Comment

by:bfeddish
ID: 22786575

I still had to piece togther the methodology for this. If you look at my code sample above I have the <EditItemTemplate>,  <ItemTemplate> and the <InsertItemTemplate> sections and it took a long time to figure those items out and get my project moving.  Displaying the data in an existing record was one thing but having the drop down box work properly with editing was another.

If this information was in either of the 2 links you sent me then I missed it. If this is the case then if possible I will have them change the grade.
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22786743
ok i see...
Has a bonus, when 2 template are the same, you could copy them in the page load event...
this exemple is for a form view, but it should work for a template field

If Not (Page.IsPostBack) Then
'the insert and edit templates are the same
            FormView1.InsertItemTemplate = FormView1.EditItemTemplate
end if
if they are almost the same you could then hide control (or set Enabled = "false" ) part in the DataBount event.
 
0
 
LVL 1

Author Comment

by:bfeddish
ID: 22786804
Thanks for the extra info.

This stuff is frustrationg because there does not seem to be too many good sources on doing everything.  Most books, websites, etc. all just scratch the surface and assume you want to just display a list of data across your screen. None go too deep on data entry forms that most of us developers have been doing for years with standard EXE applications. I can find 100 sources for changing the background color of my grid for every one that shows me how to edit data inside it.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generate Unique ID in VB.NET 21 137
YouTube API get the Video Tags - vb.net 7 54
Build a string of emails from a gridview 2 31
Run software updates from the website 6 51
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

710 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