[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

GridView is not updated

Posted on 2010-04-07
7
Medium Priority
?
477 Views
Last Modified: 2013-12-17
Dear friends,

I have a GridView, and its GridView_RowUpdating() method is called, and NewValues are set correctly... but at the end the database is not updated.
Could you help please?
<asp:SqlDataSource ID="FrontListSqlDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:BookList %>" DataSourceMode="DataSet" 
        ProviderName="<%$ ConnectionStrings:BookList.ProviderName %>" 
        UpdateCommand="UPDATE BookQuest SET `TantorStatus` = ?, `AssignedTo` = ?, `Title` = ?, `RespParty` = ?, `Publisher` = ?, `PubDate` = ?, `Subject` = ?, `Binding` = ?, `PageCount` = ?, `USListPrice` = ?, `Demand` = ?, `OnOrder` = ?, `OnBackorder` = ?, `SpeedStock` = ?, `Status` = ?, `BTKey` = ?, `FirstPrinting` = ?, `Ingram` = ?, `Licensor` = ?, `OfferDate` = ?, `LastDate` = ?, `Comments` = ?, `Note` = ?, `FirstAppearance` = ?, `Material` = ? WHERE `EAN` = ?;"

    >
        <UpdateParameters>
            <asp:Parameter Name="TantorStatus" Type="Int32" />
            <asp:Parameter Name="AssignedTo" Type="Int32" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="RespParty" Type="String" />
            <asp:Parameter Name="Publisher" Type="String" />
            <asp:Parameter Name="PubDate" Type="DateTime" />
            <asp:Parameter Name="Subject" Type="String" />
            <asp:Parameter Name="Binding" Type="String" />
            <asp:Parameter Name="PageCount" Type="Int32" />
            <asp:Parameter Name="USListPrice" Type="Double" />
            <asp:Parameter Name="Demand" Type="Int32" />
            <asp:Parameter Name="OnOrder" Type="Int32" />
            <asp:Parameter Name="OnBackorder" Type="Int32" />
            <asp:Parameter Name="SpeedStock" Type="Int32" />
            <asp:Parameter Name="Status" Type="String" />
            <asp:Parameter Name="BTKey" Type="Int32" />
            <asp:Parameter Name="FirstPrinting" Type="Int32" />
            <asp:Parameter Name="Ingram" Type="String" />
            <asp:Parameter Name="Licensor" Type="String" />
            <asp:Parameter Name="OfferDate" Type="DateTime" />
            <asp:Parameter Name="LastDate" Type="DateTime" />
            <asp:Parameter Name="Comments" Type="String" />
            <asp:Parameter Name="Note" Type="String" />
            <asp:Parameter Name="FirstAppearance" Type="DateTime" />
            <asp:Parameter Name="Material" Type="String" />
            <asp:Parameter Name="EAN" Type="String" />
        </UpdateParameters>    
    </asp:SqlDataSource>

   
    <asp:GridView ID="FrontListGridView" runat="server" AllowSorting="True" ShowFooter="True"
                    AllowPaging="True" PageSize="100" DataSourceID="FrontListSqlDataSource" 
                    AutoGenerateColumns="False" Width="2800px" Height="100%" 
                    OnRowDataBound="FrontListGridView_RowDataBound" 
                    OnRowCommand="FrontListGridView_RowCommand" OnRowUpdating="FrontListGridView_RowUpdating"
                    CssClass="largegridview" DataKeyNames="EAN" >        
            <AlternatingRowStyle CssClass="alternatingrowstyle" />
            <Columns>
                 <asp:BoundField DataField="Color" HeaderText="Color" SortExpression="Color" Visible="true" />
                 <asp:TemplateField>
                    <ItemTemplate>
                         <asp:CheckBox ID="BookSelector" runat="server" >
                         </asp:CheckBox>
                    </ItemTemplate>
                 </asp:TemplateField>  
                 
                 <asp:ButtonField Text="DoubleClick" CommandName="Edit" Visible="False" />
                                
                 <asp:TemplateField HeaderText="EAN" SortExpression="EAN">
                    <ItemTemplate>
                        <asp:Label ID="lblEAN" runat="server" Text='<%# Eval("EAN") %>'></asp:Label>
                        <%--<asp:TextBox ID="EAN" runat="server" Text='<%# Eval("EAN") %>' visible="false" CssClass="ssTextBox"></asp:TextBox>--%>
                    </ItemTemplate>
                </asp:TemplateField>
                 
                 <asp:TemplateField HeaderText="TantorStatus" SortExpression="TantorStatus">
                    <EditItemTemplate>    
                        <asp:DropDownList ID="TantorStatus" runat="server" SelectedValue='<%# Server.HtmlDecode(Convert.IsDBNull(Eval("TantorStatus")) ? string.Empty : Convert.ToString(Eval("TantorStatus")))%>' >
                            <asp:ListItem Text="" Value=""></asp:ListItem>
                            <asp:ListItem Text="Cancelled" Value="0"></asp:ListItem>
                            <asp:ListItem Text="On Offer" Value="1"></asp:ListItem> 
                            <asp:ListItem Text="For Consideration" Value="2"></asp:ListItem>    
                            <asp:ListItem Text="Make Offer" Value="3"></asp:ListItem>    
                            <asp:ListItem Text="On Hold" Value="4"></asp:ListItem>    
                        </asp:DropDownList>                       
                    </EditItemTemplate>                     
                    <ItemTemplate>                    
                        <asp:Label ID="lblTantorStatus" runat="server" Text='<%# Server.HtmlDecode(Convert.IsDBNull(Eval("TantorStatus")) ? string.Empty : tantorStatuses[Convert.ToInt32(Eval("TantorStatus"))])%>' ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                
                
                 <asp:TemplateField HeaderText="Assigned To" SortExpression="AssignedTo">
                    <EditItemTemplate>    
                        <asp:DropDownList ID="AssignedTo" runat="server" SelectedValue='<%# Server.HtmlDecode(Convert.IsDBNull(Eval("AssignedTo")) ? string.Empty : (Eval("AssignedTo")).ToString())%>'
                            DataSourceID="UserSqlDataSource" DataTextField="Name" DataValueField="ID" AppendDataBoundItems="true" >
                            <asp:ListItem Text="" Value=""></asp:ListItem>
                        </asp:DropDownList>                       
                    </EditItemTemplate>                   
                    <ItemTemplate>
                        <asp:Label ID="lblAssignTo" runat="server" Text='<%# Eval("UserName") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>  
                
                 <asp:TemplateField HeaderText="Title" SortExpression="Title">
                    <EditItemTemplate>    
                        <asp:TextBox ID="Title" runat="server" Text='<%# Eval("Title") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                    
                    <ItemTemplate>
                        <asp:Label ID="lblTitle" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                              
                <asp:TemplateField HeaderText="RespParty" SortExpression="RespParty">
                    <EditItemTemplate>    
                        <asp:TextBox ID="RespParty" runat="server" Text='<%# Eval("RespParty") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                  
                    <ItemTemplate>
                        <asp:Label ID="lblRespParty" runat="server" Text='<%# Eval("RespParty") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>               
                 
                <asp:TemplateField HeaderText="Publisher" SortExpression="Publisher">
                    <EditItemTemplate>    
                        <asp:TextBox ID="Publisher" runat="server" Text='<%# Eval("Publisher") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                   
                    <ItemTemplate>
                        <asp:Label ID="lblPublisher" runat="server" Text='<%# Eval("Publisher") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                    
                 
                <asp:TemplateField HeaderText="PubDate" SortExpression="PubDate">
                    <EditItemTemplate>    
                        <asp:TextBox ID="PubDate" runat="server" Text='<%# Eval("PubDate","{0:M/d/yyyy}") %>' Width="70px" ></asp:TextBox>
                        <asp:ImageButton runat="Server" ID="imgBtnPubDate" ImageUrl="~/Images/Calendar_scheduleHS.png" AlternateText="Click here to display calendar" />
                        <ajaxToolkit:CalendarExtender ID="PubDateCE" runat="server" TargetControlID="PubDate" PopupButtonID="imgBtnPubDate"/>                                
                        <asp:CompareValidator ID="PubDateCompareValidator" runat="server" ControlToValidate="PubDate" Display="Dynamic" ErrorMessage="Invalid PubDate!" Text="*" Operator="DataTypeCheck" Type="Date" ValidationGroup="filter" ></asp:CompareValidator>
                        <ajaxToolkit:ValidatorCalloutExtender ID="PubDateCompareValidator_ValidatorCalloutExtender" runat="server" Enabled="True" TargetControlID="PubDateCompareValidator"></ajaxToolkit:ValidatorCalloutExtender>
                   </EditItemTemplate>                  
                    <ItemTemplate>
                        <asp:Label ID="lblPubDate" runat="server" Text='<%#Eval("PubDate","{0:M/d/yyyy}") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                   
                 
                <asp:TemplateField HeaderText="Subject" SortExpression="Subject">
                    <EditItemTemplate>    
                        <asp:TextBox ID="Subject" runat="server" Text='<%# Eval("Subject") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                   
                    <ItemTemplate>
                        <asp:Label ID="lblSubject" runat="server" Text='<%# Eval("Subject") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                  
                 
                <asp:TemplateField HeaderText="Binding" SortExpression="Binding">
                    <EditItemTemplate>    
                        <asp:TextBox ID="Binding" runat="server" Text='<%# Eval("Binding") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                   
                    <ItemTemplate>
                        <asp:Label ID="lblBinding" runat="server" Text='<%# Eval("Binding") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                   
                 
                <asp:TemplateField HeaderText="Page Count" SortExpression="PageCount">
                    <EditItemTemplate>    
                        <asp:TextBox ID="PageCount" runat="server" Text='<%# Eval("PageCount") %>' Width="100%" ></asp:TextBox>
                        <asp:CompareValidator ID="PageCountCompareValidator" runat="server" ControlToValidate="PageCount" Display="Dynamic" ErrorMessage="Page Count must be an integer!" Text="*" Operator="DataTypeCheck" Type="Integer" ValidationGroup="filter" ></asp:CompareValidator>
                   </EditItemTemplate>                   
                    <ItemTemplate>
                        <asp:Label ID="lblPageCount" runat="server" Text='<%# Eval("PageCount") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                   
                 
                 <asp:TemplateField HeaderText="US List Price" SortExpression="USListPrice">
                    <EditItemTemplate>    
                        <asp:TextBox ID="USListPrice" runat="server" Text='<%# Eval("PageCount") %>' Width="100%" ></asp:TextBox>
                        <asp:CompareValidator ID="USListPriceCompareValidator" runat="server" ControlToValidate="USListPrice" Display="Dynamic" ErrorMessage="US List Price has invalid currency value!" Text="*" Operator="DataTypeCheck" Type="Currency" ValidationGroup="filter" ></asp:CompareValidator>
                   </EditItemTemplate>                       
                    <ItemTemplate>
                        <asp:Label ID="lblUSListPrice" runat="server" Text='<%# Eval("USListPrice","{0:c}") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                  
                 
                <asp:TemplateField HeaderText="Demand" SortExpression="Demand">
                    <EditItemTemplate>    
                        <asp:TextBox ID="Demand" runat="server" Text='<%# Eval("Demand") %>' Width="100%" ></asp:TextBox>
                        <asp:CompareValidator ID="DemandCompareValidator" runat="server" ControlToValidate="Demand" Display="Dynamic" ErrorMessage="Demand must be an integer!" Text="*" Operator="DataTypeCheck" Type="Integer" ValidationGroup="filter" ></asp:CompareValidator>
                   </EditItemTemplate>                       
                    <ItemTemplate>
                        <asp:Label ID="lblDemand" runat="server" Text='<%# Eval("Demand") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                   
                 
                <asp:TemplateField HeaderText="On Order" SortExpression="OnOrder">
                    <EditItemTemplate>    
                        <asp:TextBox ID="OnOrder" runat="server" Text='<%# Eval("OnOrder") %>' Width="100%" onkeypress="keyPressHandler(event)"></asp:TextBox>
                        <asp:CompareValidator ID="OnOrderCompareValidator" runat="server" ControlToValidate="OnOrder" Display="Dynamic" ErrorMessage="On Order must be an integer!" Text="*" Operator="DataTypeCheck" Type="Integer" ValidationGroup="filter" ></asp:CompareValidator>
                   </EditItemTemplate>                       
                    <ItemTemplate>
                        <asp:Label ID="lblOnOrder" runat="server" Text='<%# Eval("OnOrder") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                   
                 
                 <asp:TemplateField HeaderText="On Backorder" SortExpression="OnBackorder">
                   <EditItemTemplate>    
                        <asp:TextBox ID="OnBackorder" runat="server" Text='<%# Eval("OnBackorder") %>' Width="100%" ></asp:TextBox>
                        <asp:CompareValidator ID="OnBackorderCompareValidator" runat="server" ControlToValidate="OnBackorder" Display="Dynamic" ErrorMessage="On Backorder must be an integer!" Text="*" Operator="DataTypeCheck" Type="Integer" ValidationGroup="filter" ></asp:CompareValidator>
                   </EditItemTemplate>                       
                    <ItemTemplate>
                        <asp:Label ID="lblOnBackorder" runat="server" Text='<%# Eval("OnBackorder") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                  
                 
                 <asp:TemplateField HeaderText="SpeedStock" SortExpression="SpeedStock">
                   <EditItemTemplate>    
                        <asp:CheckBox ID="SpeedStock" runat="server" Checked='<%# Eval("SpeedStock") %>' /> 
                   </EditItemTemplate>                       
                    <ItemTemplate>
                        <asp:CheckBox ID="lblSpeedStock" runat="server" Checked='<%# Eval("SpeedStock") %>' Enabled="false" /> 
                    </ItemTemplate>
                </asp:TemplateField>                   
                 
                 <asp:TemplateField HeaderText="Status" SortExpression="Status">
                   <EditItemTemplate>    
                        <asp:TextBox ID="Status" runat="server" Text='<%# Eval("Status") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                       
                    <ItemTemplate>                    
                        <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("Status") %>' ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                   
                 
                <asp:TemplateField HeaderText="BTKey" SortExpression="BTKey">
                   <EditItemTemplate>    
                        <asp:TextBox ID="BTKey" runat="server" Text='<%# Eval("BTKey") %>' Width="100%" ></asp:TextBox>
                        <asp:CompareValidator ID="BTKeyCompareValidator" runat="server" ControlToValidate="BTKey" Display="Dynamic" ErrorMessage="BTKey must be an integer!" Text="*" Operator="DataTypeCheck" Type="Integer" ValidationGroup="filter" ></asp:CompareValidator>
                   </EditItemTemplate>                       
                    <ItemTemplate>
                        <asp:Label ID="lblBTKey" runat="server" Text='<%# Eval("BTKey") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                   
                 
                <asp:TemplateField HeaderText="First Printing" SortExpression="FirstPrinting">
                   <EditItemTemplate>    
                        <asp:TextBox ID="FirstPrinting" runat="server" Text='<%# Eval("FirstPrinting") %>' Width="100%" ></asp:TextBox>
                        <asp:CompareValidator ID="FirstPrintingCompareValidator" runat="server" ControlToValidate="BTKey" Display="Dynamic" ErrorMessage="FirstPrinting must be an integer!" Text="*" Operator="DataTypeCheck" Type="Integer" ValidationGroup="filter" ></asp:CompareValidator>
                   </EditItemTemplate>                  
                    <ItemTemplate>
                        <asp:Label ID="lblFirstPrinting" runat="server" Text='<%# Eval("FirstPrinting") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                    
                 
                 <asp:TemplateField HeaderText="Ingram" SortExpression="Ingram">
                   <EditItemTemplate>    
                        <asp:TextBox ID="Ingram" runat="server" Text='<%# Eval("Ingram") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                  
                    <ItemTemplate>                    
                        <asp:Label ID="lblIngram" runat="server" Text='<%# Eval("Ingram") %>' ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                       

                 <asp:TemplateField HeaderText="Licensor" SortExpression="Licensor">
                   <EditItemTemplate>    
                        <asp:TextBox ID="Licensor" runat="server" Text='<%# Eval("Licensor") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                  
                    <ItemTemplate>                    
                        <asp:Label ID="lblLicensor" runat="server" Text='<%# Eval("Licensor") %>' ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                   
                 
                <asp:TemplateField HeaderText="Offer Date" SortExpression="OfferDate">
                    <EditItemTemplate>    
                        <asp:TextBox ID="OfferDate" runat="server" Text='<%# Eval("OfferDate","{0:M/d/yyyy}") %>' Width="70px" ></asp:TextBox>
                        <asp:ImageButton runat="Server" ID="imgBtnOfferDate" ImageUrl="~/Images/Calendar_scheduleHS.png" AlternateText="Click here to display calendar" />
                        <ajaxToolkit:CalendarExtender ID="OfferDateCE" runat="server" TargetControlID="OfferDate" PopupButtonID="imgBtnOfferDate"/>                                
                        <asp:CompareValidator ID="OfferDateCompareValidator" runat="server" ControlToValidate="OfferDate" Display="Dynamic" ErrorMessage="Invalid Offer Date!" Text="*" Operator="DataTypeCheck" Type="Date" ValidationGroup="filter" ></asp:CompareValidator>
                        <ajaxToolkit:ValidatorCalloutExtender ID="OfferDateCompareValidator_ValidatorCalloutExtender" runat="server" Enabled="True" TargetControlID="OfferDateCompareValidator"></ajaxToolkit:ValidatorCalloutExtender>
                   </EditItemTemplate>                       
                    <ItemTemplate>
                        <asp:Label ID="lblOfferDate" runat="server" Text='<%#Eval("OfferDate","{0:M/d/yyyy}") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                  
                 
                <asp:TemplateField HeaderText="Last Date" SortExpression="LastDate">
                   <EditItemTemplate>    
                        <asp:TextBox ID="LastDate" runat="server" Text='<%# Eval("LastDate","{0:M/d/yyyy}") %>' Width="70px" ></asp:TextBox>
                        <asp:ImageButton runat="Server" ID="imgBtnLastDate" ImageUrl="~/Images/Calendar_scheduleHS.png" AlternateText="Click here to display calendar" />
                        <ajaxToolkit:CalendarExtender ID="LastDateCE" runat="server" TargetControlID="LastDate" PopupButtonID="imgBtnLastDate"/>                                
                        <asp:CompareValidator ID="LastDateCompareValidator" runat="server" ControlToValidate="LastDate" Display="Dynamic" ErrorMessage="Invalid Last Date!" Text="*" Operator="DataTypeCheck" Type="Date" ValidationGroup="filter" ></asp:CompareValidator>
                        <ajaxToolkit:ValidatorCalloutExtender ID="LastDateCompareValidator_ValidatorCalloutExtender" runat="server" Enabled="True" TargetControlID="LastDateCompareValidator"></ajaxToolkit:ValidatorCalloutExtender>
                   </EditItemTemplate>                 
                    <ItemTemplate>
                        <asp:Label ID="lblLastDate" runat="server" Text='<%#Eval("LastDate","{0:M/d/yyyy}") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                  
                 
                 <asp:TemplateField HeaderText="Comments" SortExpression="Comments">
                   <EditItemTemplate>    
                        <asp:TextBox ID="Comments" runat="server" Text='<%# Eval("Comments") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                   
                    <ItemTemplate>                    
                        <asp:Label ID="lblComments" runat="server" Text='<%# Eval("Comments") %>' ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                    
                 
                 <asp:TemplateField HeaderText="Note" SortExpression="Note">
                   <EditItemTemplate>    
                        <asp:TextBox ID="Note" runat="server" Text='<%# Eval("Note") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                   
                    <ItemTemplate>                    
                        <asp:Label ID="lblNote" runat="server" Text='<%# Eval("Note") %>' ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                  
                 
                <asp:TemplateField HeaderText="First Appearance" SortExpression="FirstAppearance">
                   <EditItemTemplate>    
                        <asp:TextBox ID="FirstAppearance" runat="server" Text='<%# Eval("FirstAppearance","{0:M/d/yyyy}") %>' Width="70px"></asp:TextBox>
                        <asp:ImageButton runat="Server" ID="imgBtnFirstAppearance" ImageUrl="~/Images/Calendar_scheduleHS.png" AlternateText="Click here to display calendar" />
                        <ajaxToolkit:CalendarExtender ID="FirstAppearanceCE" runat="server" TargetControlID="FirstAppearance" PopupButtonID="imgBtnFirstAppearance"/>                                
                        <asp:CompareValidator ID="FirstAppearanceCompareValidator" runat="server" ControlToValidate="FirstAppearance" Display="Dynamic" ErrorMessage="Invalid First Appearance Date!" Text="*" Operator="DataTypeCheck" Type="Date" ValidationGroup="filter" ></asp:CompareValidator>
                        <ajaxToolkit:ValidatorCalloutExtender ID="FirstAppearanceCompareValidator_ValidatorCalloutExtender" runat="server" Enabled="True" TargetControlID="FirstAppearanceCompareValidator"></ajaxToolkit:ValidatorCalloutExtender>
                   </EditItemTemplate>                  
                    <ItemTemplate>
                        <asp:Label ID="lblFirstAppearance" runat="server" Text='<%#Eval("FirstAppearance","{0:M/d/yyyy}") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>                     
                 
                 <asp:TemplateField HeaderText="Material" SortExpression="Material">
                   <EditItemTemplate>    
                        <asp:TextBox ID="Material" runat="server" Text='<%# Eval("Material") %>' Width="100%" ></asp:TextBox>
                   </EditItemTemplate>                  
                    <ItemTemplate>                    
                        <asp:Label ID="lblMaterial" runat="server" Text='<%# Eval("Material") %>' ></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>  
            </Columns>

            <HeaderStyle CssClass="headerstyle" />

    </asp:GridView> 

...

    protected void Page_Load(object sender, EventArgs e)
    {

        if (this.FrontListGridView.SelectedIndex > -1)
        {
            // Call UpdateRow on every postback
            try
            {                
                this.FrontListGridView.UpdateRow(this.FrontListGridView.SelectedIndex, false);
            }
            catch (Exception ex)
            {
                SetWarningLabel(ex.Message);
            }
        }
        Filter();
    }

    protected void FrontListGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        GridView gridView = (GridView)sender;

        try
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Get the LinkButton control in the third cell
                LinkButton _doubleClickButton = (LinkButton)e.Row.Cells[2].Controls[0];
                // Get the javascript which is assigned to this LinkButton
                string _jsDouble = Page.ClientScript.GetPostBackClientHyperlink(_doubleClickButton, "");

                // Add this javascript to the onclick Attribute of the row
                e.Row.Attributes["ondblclick"] = _jsDouble;
                e.Row.Attributes["style"] += "cursor:pointer;cursor:hand;";
            }
        }
        catch (Exception ex)
        {
            SetWarningLabel(ex.Message);
            return;
        }
    }

    protected void FrontListGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridView _gridView = (GridView)sender;

        switch (e.CommandName)
        {
            case ("Edit"):
                // Get the row index
                int _rowIndex = int.Parse(e.CommandArgument.ToString());

                // Set the Gridview selected index
                _gridView.SelectedIndex = _rowIndex;
                break;
        }
    }
    protected void FrontListGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridView _gridView = (GridView)sender;
        string key = "";
        string value = "";

        // The keys for the NewValues collection
        string[] _columnKeys = new string[] { "EAN", "TantorStatus", "AssignedTo", "Title", "RespParty", "Publisher", "PubDate", "Subject", "Binding", "PageCount", "USListPrice", "Demand", "OnOrder", "OnBackorder", "SpeedStock", "Status", "BTKey", "FirstPrinting", "Ingram", "Licensor", "OfferDate", "LastDate", "Comments", "Note", "FirstAppearance", "Material" };

        if (e.RowIndex > -1)
        {
            // Loop though the columns
            for (int _columnIndex = _firstEditCellIndex; _columnIndex < _gridView.Columns.Count; _columnIndex++)
            {
                // Get the controls in the cell
                //Control _displayControl = _gridView.Rows[e.RowIndex].Cells[_columnIndex].Controls[1];
                Control _editControl = _gridView.Rows[e.RowIndex].Cells[_columnIndex].Controls[1];

                // Get the column key
                key = _columnKeys[_columnIndex - _firstEditCellIndex];

                // If a cell in edit mode get the value of the edit control
                if (_editControl != null && _editControl.Visible)
                {
                    if (_editControl is Label)
                    {
                        value = ((Label)_editControl).Text;
                    }
                    if (_editControl is TextBox)
                    {
                        value = ((TextBox)_editControl).Text;
                    }
                    else if (_editControl is DropDownList)
                    {
                        value = ((DropDownList)_editControl).SelectedValue;
                    }
                    else if (_editControl is CheckBox)
                    {
                        value = ((CheckBox)_editControl).Checked ? "1" : "0";
                    }

                    // Add the key/value pair to the NewValues collection
                }
 
                e.NewValues.Add(key, value);
            }
            // Clear the selected index to prevent 
            // another update on the next postback
            _gridView.SelectedIndex = -1;
        }
    }

Open in new window

0
Comment
Question by:tantormedia
  • 4
  • 3
7 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 30039589
Add handler for GV RowUpdated as well and see if you get any exception:

protected void FrontListGridView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
    {
         Response.Write(e.Exception.Message);
    }

   <asp:GridView ID="FrontListGridView" runat="server" AllowSorting="True" ShowFooter="True"
                    AllowPaging="True" PageSize="100" DataSourceID="FrontListSqlDataSource"
                    AutoGenerateColumns="False" Width="2800px" Height="100%"
                    OnRowDataBound="FrontListGridView_RowDataBound"
                    OnRowCommand="FrontListGridView_RowCommand" OnRowUpdating="FrontListGridView_RowUpdating"
                    CssClass="largegridview" DataKeyNames="EAN"
OnRowUpdated="FrontListGridView_RowUpdated">

I think you will need to pass parameters as :
SET `TantorStatus` = @TantorStatus, `AssignedTo` = @AssignedTo,..so on
0
 

Author Comment

by:tantormedia
ID: 30042122
Thank you for your answer.
No exception was reported, e.Exception is null.
I use MySql, so I think using ? is correct.
Maybe any other suggestions?
Thanks.
0
 

Author Comment

by:tantormedia
ID: 30044519
It is so strange. I left only one parameter for updating and one to be used in Where clause, just to check if anything may be wrong with some fields. And the record was updated. Then I cautiously added some more parameters, and those fields were not updated. Then I left only one field to update again, and now even that field is not updated. I am really confused.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 41

Expert Comment

by:guru_sami
ID: 30044993
some error should be happening...can you add similar debugging message for sqldatasource updated event..

 protected void FrontListSqlDataSource_Updated(object sender, SqlDataSourceStatusEventArgs e)
    {
         Response.Write(e.Exception.Message);
    }

and also try running that update query directly in your database instead of via asp.net.
0
 

Author Comment

by:tantormedia
ID: 30046269
No error here also.
I ran
UPDATE BookQuest SET `TantorStatus` = 1
WHERE `EAN` = '9780631199557'
in QueryBrowser, and it worked. I wonder if I can see somehow the actual query that is executed?
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 2000 total points
ID: 30051842
With mySql i am not sure but if it is SqlServer you can use Sql Profiler..
Check if there is something similar for MySql...
0
 

Author Comment

by:tantormedia
ID: 30055550
Yes, and I could figure it out using that tool. It is because I have one more field that I had no need to update, but because it was bound, it was in the NewValues dictionary messing my updating up.
Thank you for your help.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses
Course of the Month9 days, 10 hours left to enroll

591 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