?
Solved

Update not working on Gridview with DropDownList

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

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 …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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