View Single Post
  #1 (permalink)  
Old August 22nd, 2007, 09:11 PM
yukijocelyn yukijocelyn is offline
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)

Hi

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] = ? ">

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

<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" />
<Fields>
<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">
         <asp:ListItem>AAA</asp:ListItem>
         <asp:ListItem>BBB</asp:ListItem>
         <asp:ListItem>CCC</asp:ListItem>
                 </asp:DropDownList>
         </EditItemTemplate>
     </asp:TemplateField>
    
</Fields>
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:DetailsView>

Please advise me on how to go about solving this problem.
Thank you!