Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 22nd, 2007, 09:11 PM
Authorized User
Join Date: Aug 2007
Location: , , Singapore.
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yukijocelyn
Default DropDownList value insert to MS DB(DetailsView)


I'm experiencing one problem here. I have a DropDownList in my Details View. However, I am unable to get its value(AAA or BBB or CCC) to be inserted into the MS Access database that I want to. The codes are as such:

<asp:AccessDataSource ID="AccessDataSource1" runat="server" ConflictDetection="CompareAllValues" DataFile="~/App_Data/DB.mdb"
DeleteCommand="DELETE FROM [table] WHERE [ID] = ?
InsertCommand="INSERT INTO [table] ([o] VALUES (?)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [ID], [o] FROM [table]"
UpdateCommand="UPDATE [table] SET [o]] = ? WHERE [ID] = ? ">

<asp:Parameter Name="o" Type="String" />

<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False" CellPadding="4" DataKeyNames="ID" DataSourceID="AccessDataSource1" DefaultMode="Insert" ForeColor="#333333" GridLines="None" Height="263px" Style="z-index: 106; left: 8px; position: absolute; top: 93px" Width="694px">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
<EditRowStyle BackColor="#2461BF" />
<RowStyle BackColor="#EFF3FB" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<asp:CommandField ShowInsertButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="allocatedID" />

<asp:BoundField DataField="o" HeaderText="o" SortExpression="o"/>
<asp:TemplateField HeaderText="Company"><EditItemTemplate>
     <asp:DropDownList ID="DropDownList1" runat="server" DataTextField="o" DataValueField="o">
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />

Please advise me on how to go about solving this problem.
Thank you!
Reply With Quote
  #2 (permalink)  
Old August 22nd, 2007, 11:31 PM
Registered User
Join Date: Apr 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

 Hope this helps u
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
DropDownList ddl = (DropDownList)sender;
string selectedStatus = ddl.SelectedValue.ToString();
or can get the value as below in any event, say for example in btnSave_Click
foreach (DetailsViewRow row in DetailsView1)
  DropDownList ddl=(DropDownList)row.FindControl("DropDownList1") ;
  string ddlItem = ddl.SelectedItem.Text;
Store the value of ddlItem in database.


Reply With Quote
  #3 (permalink)  
Old August 23rd, 2007, 01:32 AM
Authorized User
Join Date: Aug 2007
Location: , , Singapore.
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yukijocelyn

Hi Sripa!

Thank you so much for your help! I got it already! Thank you!
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot bind from DropDownList to DetailsView kiekar ASP.NET 2.0 Basics 0 February 19th, 2008 09:26 PM
Insert DropDownList(DetailsView) value toMS Access yukijocelyn ASP.NET 2.0 Professional 0 August 22nd, 2007 09:49 PM
Re-Binding A Dropdownlist In A DetailsView cyber0ne BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 March 26th, 2007 07:10 PM
ASP Insert , MS Access Db tigere Classic ASP Databases 0 November 11th, 2006 08:43 AM
dropdownlist value into detailsview: how? hertendreef ASP.NET 2.0 Professional 0 June 26th, 2006 01:54 AM

All times are GMT -4. The time now is 11:29 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.