Avatar of TonyReba
TonyReba
Flag for United States of America asked on

Update not working on Gridview with DropDownList

HI EE,

Can you help me finding out, why my update statement doesnt work? I am using ASP.NET 3.5 and the GridView Control with a dropdownlist that I manually I am assigning the items,
 the item is not updating is:
 <asp:Parameter Name="qcvalidator" Type="String" />


Ty

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                    AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Id" 
                    DataSourceID="SqlDataSource1" EnableModelValidation="True" 
                           onrowdatabound="GridView1_RowDataBound" CellPadding="4" 
                           ForeColor="#333333" GridLines="None" 
                onselectedindexchanged="GridView1_SelectedIndexChanged">
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:CommandField ShowEditButton="True" />
                        <asp:BoundField DataField="recType" HeaderText="RecType" InsertVisible="False" 
                            ReadOnly="True" SortExpression="recType" />
                        <asp:BoundField DataField="pages" HeaderText="Pages" SortExpression="pages" 
                            InsertVisible="False" ReadOnly="True" />
                        <asp:BoundField DataField="badge" HeaderText="Batch" SortExpression="badge" 
                            InsertVisible="False" ReadOnly="True" />
                        <asp:BoundField DataField="preppin" HeaderText="Preppin" 
                            SortExpression="preppin" InsertVisible="False" Visible="False" />
                        <asp:BoundField DataField="scanner" HeaderText="Scanner" 
                            SortExpression="scanner" Visible="False" />
                        <asp:BoundField DataField="recordNote" HeaderText="Notes" 
                            SortExpression="recordNote" InsertVisible="False" ReadOnly="True" />
                        <asp:BoundField DataField="entereddate" HeaderText="Date" 
                            SortExpression="entereddate" InsertVisible="False" ReadOnly="True" />
                        <asp:BoundField DataField="author" HeaderText="Entered By" 
                            SortExpression="author" InsertVisible="False" ReadOnly="True" />
                        <asp:BoundField DataField="timestamp" HeaderText="Date Entered" 
                            SortExpression="timestamp" ReadOnly="True" />
                        <asp:TemplateField HeaderText="QC Validator" SortExpression="qcvalidator">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("qcvalidator") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="dpDown1" runat="server">
                                    <asp:ListItem>-Select-</asp:ListItem>
                                          <asp:ListItem>Acevedo, Noe</asp:ListItem>
                    <asp:ListItem>Alvarado, Edelmira</asp:ListItem>
                    <asp:ListItem>Bueno, Nancy</asp:ListItem>
                                    </asp:DropDownList>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Date Validated" SortExpression="qcvalidDate">
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("qcvalidDate","{0:g}") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("qcvalidDate") %>' 
                                    Width="100px"></asp:TextBox>

                 
                                <asp:CalendarExtender ID="TextBox2_CalendarExtender" runat="server" 
                                    Enabled="True" TargetControlID="TextBox2" Format="MM/dd/yyyy" TodaysDateFormat="MM/dd/yyyy">
                                </asp:CalendarExtender>

                 
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Notes" 
                            SortExpression="qcvalidatorNote">
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("qcvalidatorNote") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox3" runat="server" Height="58px" 
                                    Text='<%# Bind("qcvalidatorNote") %>' TextMode="MultiLine" Width="170px"></asp:TextBox>
                            </EditItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle Font-Size="Small" HorizontalAlign="Center" 
                        VerticalAlign="Middle" BackColor="#507CD1" Font-Bold="True" 
                        ForeColor="White" />
                        <EditRowStyle BackColor="#FFFF66" />
                        <EmptyDataTemplate>No Records to Display</EmptyDataTemplate> 
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#EFF3FB" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                </asp:GridView>


   <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:appdevConnectionString %>"
        
        ProviderName="<%$ ConnectionStrings:appdevConnectionString.ProviderName %>" 
        
           SelectCommand="SELECT * FROM [HIM]" 
                DeleteCommand="DELETE FROM [HIM] WHERE [Id] = ?" 
                OldValuesParameterFormatString="original_{0}" 
                
 UpdateCommand="UPDATE [HIM] SET  [qcvalidator] = ?, [qcvalidDate] = ?, [qcvalidatorNote] = ? WHERE [Id] = ?" 
 FilterExpression="[entereddate] like '{0}%' and [badge] like '{1}%'">
        <DeleteParameters>
            <asp:Parameter Name="original_Id" Type="Int32" />
        </DeleteParameters>
   
        <UpdateParameters>

           
            <asp:Parameter Name="qcvalidator" Type="String" />
            <asp:Parameter Name="qcvalidDate" Type="DateTime" />
            <asp:Parameter Name="qcvalidatorNote" Type="String" />
            <asp:Parameter Name="original_Id" Type="Int32" />
        </UpdateParameters>

        
        <FilterParameters> 
                        <asp:ControlParameter ControlID="txtDateSearch" Name="Date"  
                    PropertyName="Text" Type="String" ConvertEmptyStringToNull="false" /> 
             <asp:ControlParameter ControlID="txtBadgeSearch" Name="Badge"  
                    PropertyName="Text" Type="String" ConvertEmptyStringToNull="false" /> 
             
                                
        </FilterParameters> 

     
    </asp:SqlDataSource

Open in new window

>
ASP.NETC#.NET Programming

Avatar of undefined
Last Comment
TonyReba

8/22/2022 - Mon
Bob Learned

Have you tried a ControlParameter, that is bound to the DropDownList's SelectedValue?
ASKER CERTIFIED SOLUTION
TonyReba

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
TonyReba

ASKER
found the error
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes