Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Update not working on Gridview with DropDownList

Posted on 2012-03-14
3
Medium Priority
?
521 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
[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 96

Expert Comment

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

Accepted Solution

by:
TonyReba earned 0 total points
ID: 37725730
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
ID: 37741234
found the error
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 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