locked
GridView not Updating values from SQLDataSource Bind RRS feed

  • Question

  • User-2057173053 posted

    Hello

    I have a website with 2 sqldatasources:  one supplies what I call "header" information while the other supplies detailed information.  The header information is placed in a FormView which has paging enabled.  When the user pages, I grab a templated control from the FormView and force it to be the DefaultValue for the second sqldatasource (the detailed data).  The second data source is bound to a GridView and a Chart control.

    When I page, everything acts as it should: the GridView/Chart control is changed to reflect the detailed records of the FormView control.  My problem is the edit/update feature in the GridView.  WHen a value is changed on the screen and the Update button is pressed, the value is set back to the old value.

    <%@ Page Title="IN RX Sample Editing" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" MaintainScrollPositionOnPostback="true" %>
    
    <%@ Register assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
    
    <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
    
    <asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent">
        <link rel="stylesheet" media="all" type="text/css" href="http://code.jquery.com/ui/1.9.1/themes/smoothness/jquery-ui.css" />
    		<link rel="stylesheet" media="all" type="text/css" href="Content/timepicker.css" />
    		<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    		<script type="text/javascript" src="http://code.jquery.com/ui/1.9.1/jquery-ui.min.js"></script>
    		<script type="text/javascript" src="Scripts/jQuery-Timepicker.js"></script>
    		<script type="text/javascript" src="Scripts/JQuery UI/jquery.ui.slider.js"></script> 
            <script type="text/javascript">
                $(document).ready(function () {
                    
                    $(".FilterDate").datepicker();
                    $(".UpdateClass").datetimepicker();
    
                });
            </script>
        <section class="featured">
            <div class="content-wrapper">
                <hgroup class="title">
                    <h1><%: Title %>.</h1>
                    <h2>Select dates below to get your data...</h2>
                </hgroup>
            </div>
        </section>
    </asp:Content>
    <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        </asp:UpdatePanel><table style="width: 350px;">
            <tr>
                <td><asp:Label ID="Label1" runat="server" Text="From:"></asp:Label></td>
                <td><asp:TextBox ID="TextBox1" runat="server" CssClass="FilterDate" Width="150px"></asp:TextBox></td>
                <td><asp:Label ID="Label2" runat="server" Text="To:"></asp:Label></td>
                <td><asp:TextBox ID="TextBox2" runat="server" CssClass="FilterDate" Width="150px"></asp:TextBox></td>
                <td><asp:Button ID="Button1" runat="server" Text="Submit" /></td>
            </tr>
        </table>
        <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource2" AllowPaging="True" BorderStyle="Solid" BorderWidth="1px" Width="585px" >
            <HeaderTemplate>
               <h3> <asp:Label ID="Label15" runat="server" Text="Cook Header Information"></asp:Label></h3>
            </HeaderTemplate>
            <ItemTemplate>
                <table style="width: 100%;">
                    <tr>
                        <td><b>BID:</b></td>
                        <td><asp:Label ID="BIDLabel" runat="server" Text='<%# Bind("BID") %>' /></td>
                        <td><b>Cook Start:</b></td>
                        <td><asp:Label ID="CK_TRIGGERLabel" runat="server" Text='<%# Bind("CK_TRIGGER") %>' /></td>
                    </tr>
                    <tr>
                        <td><b>Product:</b></td>
                        <td><asp:Label ID="PRODUCTLabel" runat="server" Text='<%# Bind("PRODUCT") %>' /></td>
                        <td><b>Cooldown Time:</b></td>
                        <td><asp:Label ID="Label14" runat="server" Text='<%# Bind("COOLDOWN_TIME") %>' /></td>
                    </tr>
                    <tr>
                        <td><b>Batch No:</b></td>
                        <td><asp:Label ID="BATCH_NOLabel" runat="server" Text='<%# Bind("BATCH_NO") %>' /></td>
                        <td><b>Validity Rev:</b></td>
                        <td><asp:Label ID="REVLabel" runat="server" Text='<%# Bind("REV") %>' /></td>
                    </tr>
                </table>
                </ItemTemplate>
            <PagerSettings Mode="NextPreviousFirstLast"  />
            <PagerStyle HorizontalAlign="Left" VerticalAlign="Top" />
        </asp:FormView>
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="BID,SAMPLE" DataSourceID="SqlDataSource1">
                <Columns>
                    <asp:CommandField ShowEditButton="True" />
                    <asp:BoundField DataField="BID" HeaderText="BID" ReadOnly="True" SortExpression="BID" />
                    <asp:BoundField DataField="SAMPLE" HeaderText="SAMPLE" ReadOnly="True" SortExpression="SAMPLE" />
                    <asp:BoundField DataField="TEST_TYPE" HeaderText="TEST_TYPE" SortExpression="TEST_TYPE" />
                    <asp:BoundField DataField="PRODUCT" HeaderText="PRODUCT" SortExpression="PRODUCT" />
                    <asp:BoundField DataField="BATCH_NO" HeaderText="BATCH_NO" SortExpression="BATCH_NO" />
                    <asp:BoundField DataField="ADJ_ITEM" HeaderText="ADJ_ITEM" SortExpression="ADJ_ITEM" />
                    <asp:BoundField DataField="REC_AMT" HeaderText="REC_AMT" SortExpression="REC_AMT" />
                    <asp:BoundField DataField="REQ_AMT" HeaderText="REQ_AMT" SortExpression="REQ_AMT" />
                    <asp:BoundField DataField="ACT_AMT" HeaderText="ACT_AMT" SortExpression="ACT_AMT" />
                    <asp:BoundField DataField="CAP" HeaderText="CAP" SortExpression="CAP" />
                    <asp:BoundField DataField="NAMETRE" HeaderText="NAMETRE" SortExpression="NAMETRE" />
                    <asp:BoundField DataField="AV" HeaderText="AV" SortExpression="AV" />
                    <asp:BoundField DataField="AV_PRED" HeaderText="AV_PRED" SortExpression="AV_PRED" />
                    <asp:BoundField DataField="PRED_EPT" HeaderText="PRED_EPT" SortExpression="PRED_EPT" />
                    <asp:BoundField DataField="SAMPLE_TIME" HeaderText="SAMPLE_TIME" SortExpression="SAMPLE_TIME" />
                    <asp:BoundField DataField="COOLDOWN_TIME" HeaderText="COOLDOWN_TIME" SortExpression="COOLDOWN_TIME" />
                    <asp:BoundField DataField="CK_TRIGGER" HeaderText="CK_TRIGGER" SortExpression="CK_TRIGGER" />
                    <asp:BoundField DataField="COLUMN_BYPASS" HeaderText="COLUMN_BYPASS" SortExpression="COLUMN_BYPASS" />
                    <asp:BoundField DataField="RX_WT" HeaderText="RX_WT" SortExpression="RX_WT" />
                    <asp:BoundField DataField="RECOMMEND" HeaderText="RECOMMEND" SortExpression="RECOMMEND" />
                    <asp:BoundField DataField="REC_ITEM" HeaderText="REC_ITEM" SortExpression="REC_ITEM" />
                    <asp:BoundField DataField="FINAL_FLAG" HeaderText="FINAL_FLAG" SortExpression="FINAL_FLAG" />
                    <asp:BoundField DataField="CAP_REP" HeaderText="CAP_REP" SortExpression="CAP_REP" />
                    <asp:BoundField DataField="AV_REP" HeaderText="AV_REP" SortExpression="AV_REP" />
                    <asp:BoundField DataField="INSERT_DATE" HeaderText="INSERT_DATE" SortExpression="INSERT_DATE" />
                    <asp:BoundField DataField="OPERATOR" HeaderText="OPERATOR" SortExpression="OPERATOR" />
                    <asp:BoundField DataField="SCHEDULE_TIME" HeaderText="SCHEDULE_TIME" SortExpression="SCHEDULE_TIME" />
                    <asp:BoundField DataField="REV" HeaderText="REV" SortExpression="REV" />
                    <asp:BoundField DataField="RX_WT_ACT" HeaderText="RX_WT_ACT" SortExpression="RX_WT_ACT" />
                </Columns>
            </asp:GridView>
            <asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource1" Height="500px" Width="1250px">
                
                <Series>
                  <asp:Series ChartType="Line" Name="Series1" XValueMember="CAP" YValueMembers="AV" MarkerStyle="Diamond" MarkerSize="10" ToolTip="#INDEX">
                    </asp:Series>
                </Series>
                <ChartAreas>
                    <asp:ChartArea Name="ChartArea1" >
                        
                        <AxisX IsStartedFromZero="false" Title="CAP (poise)">
    
                        </AxisX>
                        <AxisY IsStartedFromZero="false" Title="AV (mg KOH/g Alkyd)" Interval="Auto" >
                            
                        </AxisY>
                    </asp:ChartArea>
                </ChartAreas>
                <BorderSkin BackColor="#7ac0da" SkinStyle="FrameTitle1" />
            </asp:Chart>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ValpoHL %>" DeleteCommand="DELETE FROM [RX_SAMPLES] WHERE [BID] = @original_BID AND [SAMPLE] = @original_SAMPLE" InsertCommand="INSERT INTO [RX_SAMPLES] ([BID], [SAMPLE], [TEST_TYPE], [PRODUCT], [BATCH_NO], [ADJ_ITEM], [REC_AMT], [REQ_AMT], [ACT_AMT], [CAP], [NAMETRE], [AV], [AV_PRED], [PRED_EPT], [SAMPLE_TIME], [COOLDOWN_TIME], [CK_TRIGGER], [COLUMN_BYPASS], [RX_WT], [RECOMMEND], [REC_ITEM], [FINAL_FLAG], [CAP_REP], [AV_REP], [INSERT_DATE], [OPERATOR], [SCHEDULE_TIME], [REV], [RX_WT_ACT]) VALUES (@BID, @SAMPLE, @TEST_TYPE, @PRODUCT, @BATCH_NO, @ADJ_ITEM, @REC_AMT, @REQ_AMT, @ACT_AMT, @CAP, @NAMETRE, @AV, @AV_PRED, @PRED_EPT, @SAMPLE_TIME, @COOLDOWN_TIME, @CK_TRIGGER, @COLUMN_BYPASS, @RX_WT, @RECOMMEND, @REC_ITEM, @FINAL_FLAG, @CAP_REP, @AV_REP, @INSERT_DATE, @OPERATOR, @SCHEDULE_TIME, @REV, @RX_WT_ACT)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [RX_SAMPLES] WHERE ([BID] = @BID) ORDER BY [SAMPLE_TIME]" UpdateCommand="UPDATE [RX_SAMPLES] SET [TEST_TYPE] = @TEST_TYPE, [PRODUCT] = @PRODUCT, [BATCH_NO] = @BATCH_NO, [ADJ_ITEM] = @ADJ_ITEM, [REC_AMT] = @REC_AMT, [REQ_AMT] = @REQ_AMT, [ACT_AMT] = @ACT_AMT, [CAP] = @CAP, [NAMETRE] = @NAMETRE, [AV] = @AV, [AV_PRED] = @AV_PRED, [PRED_EPT] = @PRED_EPT, [SAMPLE_TIME] = @SAMPLE_TIME, [COOLDOWN_TIME] = @COOLDOWN_TIME, [CK_TRIGGER] = @CK_TRIGGER, [COLUMN_BYPASS] = @COLUMN_BYPASS, [RX_WT] = @RX_WT, [RECOMMEND] = @RECOMMEND, [REC_ITEM] = @REC_ITEM, [FINAL_FLAG] = @FINAL_FLAG, [CAP_REP] = @CAP_REP, [AV_REP] = @AV_REP, [INSERT_DATE] = @INSERT_DATE, [OPERATOR] = @OPERATOR, [SCHEDULE_TIME] = @SCHEDULE_TIME, [REV] = @REV, [RX_WT_ACT] = @RX_WT_ACT WHERE [BID] = @original_BID AND [SAMPLE] = @original_SAMPLE">
            <DeleteParameters>
                <asp:Parameter Name="original_BID" Type="String" />
                <asp:Parameter Name="original_SAMPLE" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="BID" Type="String" />
                <asp:Parameter Name="SAMPLE" Type="String" />
                <asp:Parameter Name="TEST_TYPE" Type="String" />
                <asp:Parameter Name="PRODUCT" Type="String" />
                <asp:Parameter Name="BATCH_NO" Type="String" />
                <asp:Parameter Name="ADJ_ITEM" Type="String" />
                <asp:Parameter Name="REC_AMT" Type="Single" />
                <asp:Parameter Name="REQ_AMT" Type="Single" />
                <asp:Parameter Name="ACT_AMT" Type="Single" />
                <asp:Parameter Name="CAP" Type="Single" />
                <asp:Parameter Name="NAMETRE" Type="Single" />
                <asp:Parameter Name="AV" Type="Single" />
                <asp:Parameter Name="AV_PRED" Type="Single" />
                <asp:Parameter Name="PRED_EPT" Type="Single" />
                <asp:Parameter Name="SAMPLE_TIME" Type="DateTime" />
                <asp:Parameter Name="COOLDOWN_TIME" Type="DateTime" />
                <asp:Parameter Name="CK_TRIGGER" Type="DateTime" />
                <asp:Parameter Name="COLUMN_BYPASS" Type="DateTime" />
                <asp:Parameter Name="RX_WT" Type="Single" />
                <asp:Parameter Name="RECOMMEND" Type="String" />
                <asp:Parameter Name="REC_ITEM" Type="String" />
                <asp:Parameter Name="FINAL_FLAG" Type="Int32" />
                <asp:Parameter Name="CAP_REP" Type="Int32" />
                <asp:Parameter Name="AV_REP" Type="Int32" />
                <asp:Parameter Name="INSERT_DATE" Type="DateTime" />
                <asp:Parameter Name="OPERATOR" Type="String" />
                <asp:Parameter Name="SCHEDULE_TIME" Type="DateTime" />
                <asp:Parameter Name="REV" Type="Int32" />
                <asp:Parameter Name="RX_WT_ACT" Type="Double" />
            </InsertParameters>
            <SelectParameters>
                <asp:Parameter Name="BID" Type="String" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="TEST_TYPE" Type="String" />
                <asp:Parameter Name="PRODUCT" Type="String" />
                <asp:Parameter Name="BATCH_NO" Type="String" />
                <asp:Parameter Name="ADJ_ITEM" Type="String" />
                <asp:Parameter Name="REC_AMT" Type="Single" />
                <asp:Parameter Name="REQ_AMT" Type="Single" />
                <asp:Parameter Name="ACT_AMT" Type="Single" />
                <asp:Parameter Name="CAP" Type="Single" />
                <asp:Parameter Name="NAMETRE" Type="Single" />
                <asp:Parameter Name="AV" Type="Single" />
                <asp:Parameter Name="AV_PRED" Type="Single" />
                <asp:Parameter Name="PRED_EPT" Type="Single" />
                <asp:Parameter Name="SAMPLE_TIME" Type="DateTime" />
                <asp:Parameter Name="COOLDOWN_TIME" Type="DateTime" />
                <asp:Parameter Name="CK_TRIGGER" Type="DateTime" />
                <asp:Parameter Name="COLUMN_BYPASS" Type="DateTime" />
                <asp:Parameter Name="RX_WT" Type="Single" />
                <asp:Parameter Name="RECOMMEND" Type="String" />
                <asp:Parameter Name="REC_ITEM" Type="String" />
                <asp:Parameter Name="FINAL_FLAG" Type="Int32" />
                <asp:Parameter Name="CAP_REP" Type="Int32" />
                <asp:Parameter Name="AV_REP" Type="Int32" />
                <asp:Parameter Name="INSERT_DATE" Type="DateTime" />
                <asp:Parameter Name="OPERATOR" Type="String" />
                <asp:Parameter Name="SCHEDULE_TIME" Type="DateTime" />
                <asp:Parameter Name="REV" Type="Int32" />
                <asp:Parameter Name="RX_WT_ACT" Type="Double" />
                <asp:Parameter Name="original_BID" Type="String" />
                <asp:Parameter Name="original_SAMPLE" Type="String" />
            </UpdateParameters>
            </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ValpoHL %>" SelectCommand="SELECT DISTINCT [BID], [PRODUCT], [BATCH_NO], [CK_TRIGGER], [COOLDOWN_TIME], [REV] FROM [RX_SAMPLES] WHERE (([CK_TRIGGER] &lt; @CK_TRIGGER) AND ([CK_TRIGGER] &gt; @CK_TRIGGER2)) ORDER BY [CK_TRIGGER]">
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBox2" Name="CK_TRIGGER" PropertyName="Text" Type="DateTime" />
                <asp:ControlParameter ControlID="TextBox1" Name="CK_TRIGGER2" PropertyName="Text" Type="DateTime" />
            </SelectParameters>
        </asp:SqlDataSource>
    </asp:Content>
    

    The code behind: 

    Partial Class _Default
        Inherits Page
    
        Dim FmPage As Integer
    
    
        Protected Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
            TextBox1.Text = DateAdd(DateInterval.Day, -14, Date.Today())
            TextBox2.Text = Date.Today()
        End Sub
    
        Protected Sub Page_SaveStateComplete(sender As Object, e As EventArgs) Handles Me.SaveStateComplete
            Dim myformview As FormView = FormView1
    
            Dim mylabel As Label = myformview.FindControl("BIDLabel")
    
            SqlDataSource1.SelectParameters.Item("BID").DefaultValue = mylabel.Text
    
            mylabel = myformview.FindControl("PRODUCTLabel")
    
            Dim myformview2 As FormView = FormView1
    
            Dim mylabel2 As Label = myformview2.FindControl("BATCH_NOLabel")
    
            Dim title As String = "Batch Curve for " & mylabel.Text & " " & mylabel2.Text
    
    
            Chart1.Titles.Add(title)
    
            Chart1.Titles(0).Font = New Drawing.Font("Verdana", 16.0F)
            Chart1.ChartAreas(0).AxisX.Maximum = getmax()
            Chart1.ChartAreas(0).AxisX.Minimum = getmin()
            Chart1.ChartAreas(0).AxisX.Interval = getspread()
    
    
        End Sub
    
        Public Function getmin() As Double
    
            Dim RS As System.Data.DataView
            Dim min As Double
            Dim max As Double
            Dim sprd As Double
            Dim e_sprd As String
            Dim X_sprd As Double
            Dim X_sprd_chk As String
            Dim Y_sprd As Double
            Dim x_min As Double
            Dim x_max As Double
            Dim increment As Double
    
            RS = Me.SqlDataSource1.Select(DataSourceSelectArguments.Empty)
    
            For i = 0 To RS.Table.Rows.Count - 1
                If i = 0 Then
                    min = RS.Table.Rows(i)("CAP")
                ElseIf RS.Table.Rows(i)("CAP") < min Then
                    min = RS.Table.Rows(i)("CAP")
                End If
                If i = 0 Then
                    max = RS.Table.Rows(i)("CAP")
                ElseIf RS.Table.Rows(i)("CAP") > max Then
                    max = RS.Table.Rows(i)("CAP")
                End If
            Next
    
            sprd = max - min
    
            e_sprd = String.Format("{0,16:0.00000e+00}", sprd)
    
            X_sprd = CDbl(Left(e_sprd, 12))
            X_sprd_chk = Left(e_sprd, 7)
            Y_sprd = CDbl(Right(e_sprd, 2))
    
            If X_sprd >= 3.5 Then
                increment = (1 * (10 ^ Y_sprd))
            ElseIf X_sprd >= 2.0 And X_sprd <= 3.49999999 Then
                increment = (0.5 * (10 ^ Y_sprd))
            ElseIf X_sprd >= 1.0 And X_sprd <= 1.99999999 Then
                increment = (0.25 * (10 ^ Y_sprd))
            End If
    
            x_min = Math.Round(min / increment, 0) * increment - increment
            x_max = max + (min - x_min) + increment
    
            Return x_min
    
        End Function
    
        Public Function getmax() As Double
    
            Dim RS As System.Data.DataView
            Dim min As Double
            Dim max As Double
            Dim sprd As Double
            Dim e_sprd As String
            Dim X_sprd As Double
            Dim X_sprd_chk As String
            Dim Y_sprd As Double
            Dim x_min As Double
            Dim x_max As Double
            Dim increment As Double
    
            RS = Me.SqlDataSource1.Select(DataSourceSelectArguments.Empty)
    
            For i = 0 To RS.Table.Rows.Count - 1
                If i = 0 Then
                    min = RS.Table.Rows(i)("CAP")
                ElseIf RS.Table.Rows(i)("CAP") < min Then
                    min = RS.Table.Rows(i)("CAP")
                End If
                If i = 0 Then
                    max = RS.Table.Rows(i)("CAP")
                ElseIf RS.Table.Rows(i)("CAP") > max Then
                    max = RS.Table.Rows(i)("CAP")
                End If
            Next
    
            sprd = max - min
    
            e_sprd = String.Format("{0,16:0.00000e+00}", sprd)
    
            X_sprd = Left(e_sprd, 12)
            X_sprd_chk = Left(e_sprd, 7)
            Y_sprd = Right(e_sprd, 2)
    
            If X_sprd >= 3.5 Then
                increment = (1 * (10 ^ Y_sprd))
            ElseIf X_sprd >= 2.0 And X_sprd <= 3.49999999 Then
                increment = (0.5 * (10 ^ Y_sprd))
            ElseIf X_sprd >= 1.0 And X_sprd <= 1.99999999 Then
                increment = (0.25 * (10 ^ Y_sprd))
            End If
    
            x_min = Math.Round(min / increment, 0) * increment - increment
            x_max = max + (min - x_min) + increment
    
            Return x_max
    
        End Function
    
        Public Function getspread() As Double
    
            Dim RS As System.Data.DataView
            Dim min As Double
            Dim max As Double
            Dim sprd As Double
            Dim e_sprd As String
            Dim X_sprd As Double
            Dim Y_sprd As Double
            Dim x_min As Double
            Dim x_max As Double
            Dim increment As Double
    
            RS = Me.SqlDataSource1.Select(DataSourceSelectArguments.Empty)
    
            For i = 0 To RS.Table.Rows.Count - 1
                If i = 0 Then
                    min = RS.Table.Rows(i)("CAP")
                ElseIf RS.Table.Rows(i)("CAP") < min Then
                    min = RS.Table.Rows(i)("CAP")
                End If
                If i = 0 Then
                    max = RS.Table.Rows(i)("CAP")
                ElseIf RS.Table.Rows(i)("CAP") > max Then
                    max = RS.Table.Rows(i)("CAP")
                End If
            Next
    
            sprd = max - min
    
            e_sprd = String.Format("{0,16:0.00000e+00}", sprd)
    
            X_sprd = Left(e_sprd, 12)
            Y_sprd = Right(e_sprd, 2)
    
            If X_sprd >= 3.5 Then
                increment = (1 * (10 ^ Y_sprd))
            ElseIf X_sprd >= 2.0 And X_sprd <= 3.49999999 Then
                increment = (0.5 * (10 ^ Y_sprd))
            ElseIf X_sprd >= 1.0 And X_sprd <= 1.99999999 Then
                increment = (0.25 * (10 ^ Y_sprd))
            End If
    
            x_min = Math.Round(min / increment, 0) * increment - increment
            x_max = max + (min - x_min) + increment
    
            Return increment
    
        End Function
    
    
    
    
    End Class

    I was hoping to use the automatic databinding capabilities in VS...

    Wednesday, January 23, 2013 6:23 PM

Answers

  • User-2057173053 posted

    Found the issue.  Newbie mistake.

    I was setting the default value of the select parameter in SqlDataSource1 to the text value of a control within the FormView and I was doing this upon SaveStateCOmplete.

    I changed the default value to reference the SqlDataSource2 dataset upon the FormView's PageIndexChanged handle.  This seems to have solved the issue.

        Protected Sub FormView1_PageIndexChanged(sender As Object, e As EventArgs) Handles FormView1.PageIndexChanged
    
            Dim page As Integer = FormView1.PageIndex
    
            Dim RS As System.Data.DataView
    
            RS = SqlDataSource2.Select(DataSourceSelectArguments.Empty)
    
            SqlDataSource1.SelectParameters.Item("BID").DefaultValue = RS.Table.Rows(page)("BID")
    
    
        End Sub

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 1, 2013 8:16 AM

All replies

  • User-1716253493 posted

    Try this :       

    UpdateCommand="UPDATE [RX_SAMPLES] SET [TEST_TYPE] = @TEST_TYPE, [PRODUCT] = @PRODUCT, [BATCH_NO] = @BATCH_NO, [ADJ_ITEM] = @ADJ_ITEM, [REC_AMT] = @REC_AMT, [REQ_AMT] = @REQ_AMT, [ACT_AMT] = @ACT_AMT, [CAP] = @CAP, [NAMETRE] = @NAMETRE, [AV] = @AV, [AV_PRED] = @AV_PRED, [PRED_EPT] = @PRED_EPT, [SAMPLE_TIME] = @SAMPLE_TIME, [COOLDOWN_TIME] = @COOLDOWN_TIME, [CK_TRIGGER] = @CK_TRIGGER, [COLUMN_BYPASS] = @COLUMN_BYPASS, [RX_WT] = @RX_WT, [RECOMMEND] = @RECOMMEND, [REC_ITEM] = @REC_ITEM, [FINAL_FLAG] = @FINAL_FLAG, [CAP_REP] = @CAP_REP, [AV_REP] = @AV_REP, [INSERT_DATE] = @INSERT_DATE, [OPERATOR] = @OPERATOR, [SCHEDULE_TIME] = @SCHEDULE_TIME, [REV] = @REV, [RX_WT_ACT] = @RX_WT_ACT WHERE [BID] = @BID"

     

    <UpdateParameters> 
                <asp:Parameter Name="TEST_TYPE" Type="String" /> 
                <asp:Parameter Name="PRODUCT" Type="String" /> 
                <asp:Parameter Name="BATCH_NO" Type="String" /> 
                <asp:Parameter Name="ADJ_ITEM" Type="String" /> 
                <asp:Parameter Name="REC_AMT" Type="Single" /> 
                <asp:Parameter Name="REQ_AMT" Type="Single" /> 
                <asp:Parameter Name="ACT_AMT" Type="Single" /> 
                <asp:Parameter Name="CAP" Type="Single" /> 
                <asp:Parameter Name="NAMETRE" Type="Single" /> 
                <asp:Parameter Name="AV" Type="Single" /> 
                <asp:Parameter Name="AV_PRED" Type="Single" /> 
                <asp:Parameter Name="PRED_EPT" Type="Single" /> 
                <asp:Parameter Name="SAMPLE_TIME" Type="DateTime" /> 
                <asp:Parameter Name="COOLDOWN_TIME" Type="DateTime" /> 
                <asp:Parameter Name="CK_TRIGGER" Type="DateTime" /> 
                <asp:Parameter Name="COLUMN_BYPASS" Type="DateTime" /> 
                <asp:Parameter Name="RX_WT" Type="Single" /> 
                <asp:Parameter Name="RECOMMEND" Type="String" /> 
                <asp:Parameter Name="REC_ITEM" Type="String" /> 
                <asp:Parameter Name="FINAL_FLAG" Type="Int32" /> 
                <asp:Parameter Name="CAP_REP" Type="Int32" /> 
                <asp:Parameter Name="AV_REP" Type="Int32" /> 
                <asp:Parameter Name="INSERT_DATE" Type="DateTime" /> 
                <asp:Parameter Name="OPERATOR" Type="String" /> 
                <asp:Parameter Name="SCHEDULE_TIME" Type="DateTime" /> 
                <asp:Parameter Name="REV" Type="Int32" /> 
                <asp:Parameter Name="RX_WT_ACT" Type="Double" /> 
                <asp:Parameter Name="BID" Type="String" /> 
            </UpdateParameters> 


    Wednesday, January 23, 2013 7:27 PM
  • User-2057173053 posted

    Thanks for replying so quickly, oned_gk. 

    Unfortunately, the table has a clustered PK (SAMPLE and BID are the PKs) so that would not work.

    Thursday, January 24, 2013 8:47 AM
  • User3866881 posted

    Hi,

    Please don't forget to set the ConflictDetection to CompareAllValues:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues">
    </asp:SqlDataSource>
    
    Thursday, January 24, 2013 9:03 PM
  • User-2057173053 posted

    I had set the sqldatasource to optimistic concurrency in the wizard but that didn't do the trick either.

    I added a handler for SQLDataSource1's Updated event.  It never gets referenced, which I kinda expected.

    I then copied the webpage into another default page and removed the formview and put a simple textbox that updates sqldatasource1 in the SaveStateComplete subroutine.  This format allowed updating.  That seems to point to the fact that the problem lies in the GridView's dependence on the FormView control.  Any ideas on what I can do about that?

    Friday, January 25, 2013 10:16 AM
  • User3866881 posted

    put a simple textbox that updates sqldatasource1 in the SaveStateComplete subroutine.

    Where did you put the TextBox? Outside the GridView?

    I suspect whether your original TextBoxes are inside the FormView?

    Friday, January 25, 2013 8:52 PM
  • User-2057173053 posted

    Found the issue.  Newbie mistake.

    I was setting the default value of the select parameter in SqlDataSource1 to the text value of a control within the FormView and I was doing this upon SaveStateCOmplete.

    I changed the default value to reference the SqlDataSource2 dataset upon the FormView's PageIndexChanged handle.  This seems to have solved the issue.

        Protected Sub FormView1_PageIndexChanged(sender As Object, e As EventArgs) Handles FormView1.PageIndexChanged
    
            Dim page As Integer = FormView1.PageIndex
    
            Dim RS As System.Data.DataView
    
            RS = SqlDataSource2.Select(DataSourceSelectArguments.Empty)
    
            SqlDataSource1.SelectParameters.Item("BID").DefaultValue = RS.Table.Rows(page)("BID")
    
    
        End Sub

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 1, 2013 8:16 AM