Solved

Update not working on Gridview with DropDownList

Posted on 2012-03-14
3
510 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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