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
Solved

ASp.net gridview Dropdown

Posted on 2011-09-29
3
463 Views
Last Modified: 2012-05-12
Hello I have been working on trying to use the updatecommand and insert command using SqlDataSource. I have a oracle back end.  I have attached the code for your review

Error message:

 ddCoverage' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value Dropdownlist-code.txt
<asp:GridView ID="_gwFinancial" runat="server" allowPaging="True" AllowSorting="True" 
                AutoGenerateColumns="False" HorizontalAlign="Center" CellSpacing="3" CellPadding="10" 
                  DataKeyNames="ACCOUNT_CODING_MATRIX_SK"    DataSourceID="OracleFinance"  CssClass="grid"
                EmptyDataText="There are no data records to display." 
                ForeColor="#333333" GridLines="None"  ShowFooter="true">
        
         <Columns>
          <asp:TemplateField HeaderText="Commands" ItemStyle-HorizontalAlign="Center"  ItemStyle-VerticalAlign="Middle">
                <ItemTemplate>
                    <asp:Button  Width="50px" runat="server" ID="Edit" Text="Edit" CommandName="Edit" />

                </ItemTemplate>

                <EditItemTemplate>
                    <asp:Button runat="server" Width="50px" ID="Update" Text="Update" CommandName="Update" />
                    <asp:Button runat="server" Width="75px" ID="Cancel" Text="Cancel" CommandName="Cancel" />
                </EditItemTemplate>

                <FooterTemplate>
                    <asp:Button runat="server" Width="75px" ID="Insert" Text="Insert" CommandName="Insert" />
                    <asp:Button runat="server" Width="75px" ID="Cancel" Text="Cancel" CommandName="Cancel" />
                </FooterTemplate>
            </asp:TemplateField>
            
            
            
            
                        <asp:TemplateField HeaderText="ACCOUNT_CODING_MATRIX_SK" 
                            SortExpression="ACCOUNT_CODING_MATRIX_SK" Visible="False">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" 
                                    Text='<%# Bind("ACCOUNT_CODING_MATRIX_SK") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("ACCOUNT_CODING_MATRIX_SK") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
            
            
            
            
            
            
            
            
            
            
                        <asp:TemplateField HeaderText="COVERAGE_TYPE" SortExpression="COVERAGE_TYPE">
                            <EditItemTemplate>
                                   <asp:DropDownList ID="ddCoverage" runat="server" 
                                     DataTextField="COVERAGE_TYPE" DataValueField="COVERAGE_TYPE"
                                     SelectedValue='<%# Bind("COVERAGE_TYPE") %>'>
                                    <asp:ListItem Text="PY" Value="Prior Year"/>
                                    <asp:ListItem Text="CY" Value="Current Year"/>
                                     <asp:ListItem Text="FP" Value="Future Period"/>
                                   </asp:DropDownList>
                                   
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("COVERAGE_TYPE") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Width="80px" />
                            <ItemStyle HorizontalAlign="Center" />
                           <FooterTemplate>
                               <asp:DropDownList ID="ddCoverage" runat="server" 
                                     DataTextField="COVERAGE_TYPE" DataValueField="COVERAGE_TYPE"
                                     SelectedValue='<%# Bind("COVERAGE_TYPE") %>'>
                                    <asp:ListItem Text="PY" Value="Prior Year"/>
                                    <asp:ListItem Text="CY" Value="Current Year"/>
                                     <asp:ListItem Text="FP" Value="Future Period"/>
                                   </asp:DropDownList>
                            </FooterTemplate>
                          
                        </asp:TemplateField>
                        
            
            
            
            
            
         
        
        
        
        
        
        </Columns>
        
         <RowStyle BackColor="#E3EAEB" />
         <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
         <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
         <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
         <AlternatingRowStyle BackColor="White" />  
         
         
      
        </asp:GridView>
        
        
        <asp:SqlDataSource ID="OracleFinance" runat="server"  DataSourceMode="DataSet" EnableCaching="false"
                     ConnectionString="<%$ ConnectionStrings:OrcConn %>"
                      SelectCommand="SELECT ACCOUNT_CODING_MATRIX_SK,COVERAGE_TYPE FROM FDS.CFG_ACCOUNT_CODING_MATRIX" 
                            ProviderName="System.Data.OracleClient" InsertCommandType="Text"
                       InsertCommand="INSERT INTO [FDS.CFG_STAT_REPORT_DEFINITION] (STAT_RPT_ID, STAT_RPT_GRP,MTV_GROUP_TYPE,PRODUCT,BENEFIT_PACKAGE,EMPLOYEE_CNT_LOW,EMPLOYEE_CNT_HIGH) VALUES (:STAT_RPT_ID,:STAT_RPT_GRP, :MTV_GROUP_TYPE, :PRODUCT, :BENEFIT_PACKAGE, :EMPLOYEE_CNT_LOW, :EMPLOYEE_CNT_HIGH)" 
                        UpdateCommand="UPDATE FDS.CFG_ACCOUNT_CODING_MATRIX SET COVERAGE_TYPE =:COVERAGETYPE_ID  WHERE (ACCOUNT_CODING_MATRIX_SK = :ACCOUNT_CODING_MATRIX_SK)">
                         
                          <InsertParameters>
                               <asp:Parameter Name="COVERAGE_TYPE" Type="String" />
                              
                        </InsertParameters>
                        <UpdateParameters>
                                <asp:Parameter Name="COVERAGE_TYPE"   Type="String" /> 
                               
                        </UpdateParameters>
                      
               
                    </asp:SqlDataSource>

Open in new window

0
Comment
Question by:DevoinIT
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
jagssidurala earned 500 total points
ID: 36817187
this error will occured if you are assign a value to dropdown before binding datasource to it. check your code again
0
 
LVL 12

Expert Comment

by:jagssidurala
ID: 36817201
Selected values should be in the defined list.

i.e., Prior Year,  Current Year  OR Future Period


0
 

Author Closing Comment

by:DevoinIT
ID: 37457868
this worked fine
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Import Data from Multiple Text Files in Excel 12 61
Finding the IIS version 5 21
run a stored procedure from vb.net 1 27
Where does legacy ASP.NET initialize language? 2 24
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

860 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