Solved

ASp.net gridview Dropdown

Posted on 2011-09-29
3
464 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
[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
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

Industry Leaders: 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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

740 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