Solved

Update not working on Gridview with DropDownList

Posted on 2012-03-14
3
505 Views
Last Modified: 2012-03-20
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

>
0
Comment
Question by:TonyReba
  • 2
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Have you tried a ControlParameter, that is bound to the DropDownList's SelectedValue?
0
 
LVL 9

Accepted Solution

by:
TonyReba earned 0 total points
Comment Utility
Yes, actually I found the issue, I needed to set the select value on the dropdownlist to

SelectedValue='<%# Bind("qcvalidator") %>'


Thanks anyways!!
0
 
LVL 9

Author Closing Comment

by:TonyReba
Comment Utility
found the error
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now