Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASp.net gridview Dropdown

Posted on 2011-09-29
3
Medium Priority
?
471 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 1500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
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…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

971 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