Solved

my ajax updatepanel will not update

Posted on 2008-10-15
2
487 Views
Last Modified: 2010-04-21
I had this working earlier. I am not sure what I did to mess it up but my ajax call is not updateing my updatepanel results


<%@ Page Language="VB"  Debug="true"  %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<link href="../styles/rvistyle70.css" type="text/css" rel="STYLESHEET"/>
<script type="text/javascript" src="../ajax/ajax.js"></script>

<link href="file:///C:\Inetpub\wwwroot\po\rvistyle70.css" rel="stylesheet" type="text/css" />

<script runat="server">

    Protected Sub partIDTextBox0_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        'supplierTextBox.Attributes.Add("onkeyup", "callAjax()")
        If Page.IsPostBack = False Then
            'This is the query to get the different warehouse centers It is bound to the locationDeopDown
            ' Dim conn2000, adapt, DataSet, dbread, dbconn, Statement
            'Dim strSQL As String
            'strSQL = "SELECT pkey as pkey,description as description FROM imtbl_warehouse"
            ' Dim DBCommand As New SqlDataAdapter(strSQL, ConfigurationSettings.AppSettings("connString2000"))
            ' Dim ds As New DataSet
            ' DBCommand.Fill(ds)
            'NewList.DataSource = ds
            'NewList.DataBind()
         
            'locationDropDown.DataSource = ds
         
            'locationDropDown.DataTextField = "description"
            'locationDropDown.DataValueField = "pkey"
            'locationDropDown.DataBind()
         
            'This is the query retrieve thoses who have user profiles in imate
         
            'Dim strSQLState As String
            ' strSQLState = "select id,description from imtbl_state"
            'Dim DBCommandState As New SqlDataAdapter(strSQLState, ConfigurationSettings.AppSettings("connString2000"))
            'Dim stateRS As New DataSet
            'DBCommandState.Fill(stateRS)
            'stateDropDown.DataSource = stateRS
            'stateDropDown.DataTextField = "description"
            'stateDropDown.DataValueField = "id"
            'stateDropDown.DataBind()
           
           
            'Dim strSQLProfile As String
            'strSQLProfile = "select a.description as ContactName,a.id as ContactID,a.pkey as ContactPkey,c.id,c.pkey as ContactTypePkey,e.description as Warehouse from imtbl_contact a inner join imtbl_contact_contact_type b on(a.pkey=b.contact) inner join imtbl_contact_type c on(b.contact_type=c.pkey) inner join imtbl_user_profile d on(a.id=d.user_id) inner join imtbl_warehouse e on(d.default_warehouse=e.pkey) order by c.id"
            'Dim DBCommandProfile As New SqlDataAdapter(strSQLProfile, ConfigurationSettings.AppSettings("connString2000"))
            'Dim profileRS As New DataSet
            'DBCommandProfile.Fill(profileRS)
         
         
            'csRepDropDown.DataSource = profileRS
         
            ' csRepDropDown.DataTextField = "ContactName"
            'csRepDropDown.DataValueField = "ContactPkey"
            ' csRepDropDown.DataBind()
            vendorDropDown.Items.Insert(0, New ListItem("Choose...", ""))
            vehicleDropDown.Items.Insert(0, New ListItem("Choose...", ""))
            stateDropDown.Items.Insert(0, New ListItem("OK", "OK"))
            locationDropDown.Items.Insert(0, New ListItem("Choose...", ""))
            csRepDropDown.Items.Insert(0, New ListItem("Choose...", ""))
                     
        End If
         
    End Sub

   
    Protected Sub csRepDropDown_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

    Protected Sub locationDropDown_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

    Protected Sub cleaningCheckBox_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        If cleaningCheckBox.Checked = True Then
            loadNumberTextBox.Visible = True
            loadLabel.Visible = True
        Else
            loadNumberTextBox.Visible = False
            loadLabel.Visible = False
        End If
    End Sub

    Protected Sub vendorTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

   
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim cnn As New SqlConnection("Database=UPT_Demo;Server=OKCDB01;uid=po_test;password=mypassword")
        Dim InsertCommand As SqlCommand = New SqlCommand()
        InsertCommand.Connection = cnn
        Dim sqlInsert As String
        sqlInsert = "INSERT INTO imtbl_templineitem (sessionID, description, unitPrice, extendedAmount, vehicleNumber, qty) VALUES     ("
       
        sqlInsert += "'" + qtyTextBox.Text + "',"
        sqlInsert += "'" + descriptionItemTextBox.Text + "',"
        sqlInsert += priceTextBox.Text + ","
        sqlInsert += extendedTextBox.Text + ","
        sqlInsert += vehicleDropDown.SelectedValue + ","
        sqlInsert += qtyTextBox.Text + ")"
        InsertCommand.CommandText = sqlInsert
           
        cnn.Open()
        InsertCommand.ExecuteNonQuery()
           
        cnn.Close()

    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>INSERT PO</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>
    <div>
        <img src="http://www.otl-upt.com/Imagesdemand/images/otl_upt4.jpg" width="441" height="111" border="0"
        alt="Oklahoma Tank Lines / United Petroleum Transports"
        style="top: 15px; left: 242px; position: absolute"/><p>
            &nbsp;</p>
   
    </div>
    <hr style="top: 137px; left: 175px; position: absolute; height: 2px; width: 600px" />
       
<div id="title2"
        style="top: 167px; left: 175px; position: absolute; height: 8px; width: 600px">Purchase Order Entry</div>






<hr style="top: 875px; left: 175px; position: absolute; height: 2px; width: 600px" />

<a href="searchPO.aspx"
   
            style="display:block; top: 895px; left: 400px; position: absolute; height: 25px; width: 400px;">
     <img src="http://www.otl-upt.com/imagesDemand/images/button.gif" border="0" / ><font size="1">SEARCH/EDIT</font></a>
<a href="enterPO.aspx"
   
            style="display:block; top: 895px; left: 500px; position: absolute; height: 25px; width: 400px;">
     <img src="http://www.otl-upt.com/imagesDemand/images/button.gif" border="0" / ><font size="1">ENTER PO</font></a>
    <p>

   
   
    <asp:Label ID="Label1"
        style="display:block; top: 300px; left: 165px; position: absolute; height: 21px; width: 91px;"
        runat="server" Text="<b>Descripition:</b>"></asp:Label>

   
       
        </p>
   
   
    <p>

   
   
    <asp:DropDownList ID="csRepDropDown" runat="server"
       
        style="top: 250px; left: 260px; position: absolute; height: 22px; width: 135px; bottom: 92px;"  
        DataSourceID="SqlDataSource3" DataTextField="ContactName"
            DataValueField="ContactPkey" AutoPostBack="True"
        AppendDataBoundItems="True"
        onselectedindexchanged="csRepDropDown_SelectedIndexChanged">
       
    </asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSource7" runat="server"
                    ConnectionString="<%$ ConnectionStrings:UPT_DemoConnectionString %>"
                    SelectCommand="SELECT id, description FROM dbo.imtbl_asset">
                </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server"
            ConnectionString="<%$ ConnectionStrings:UPT_DemoConnectionString %>"
            SelectCommand="select a.description as ContactName,a.id as ContactID,a.pkey as ContactPkey,c.id,c.pkey as ContactTypePkey,e.description as Warehouse from imtbl_contact a inner join imtbl_contact_contact_type b on(a.pkey=b.contact) inner join imtbl_contact_type c on(b.contact_type=c.pkey) inner join imtbl_user_profile d on(a.id=d.user_id) inner join imtbl_warehouse e on(d.default_warehouse=e.pkey) order by c.id">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource6" runat="server"
                    ConnectionString="<%$ ConnectionStrings:UPT_DemoConnectionString %>" SelectCommand="SELECT      a.id, a.description
FROM         imtbl_contact a INNER JOIN
                      imtbl_contact_contact_type b ON a.pkey = b.contact
WHERE     (b.contact_type = 2)  order by a.description"></asp:SqlDataSource>
    <asp:Label ID="csRepLabel"
        style="display:block; top: 250px; left: 195px; position: absolute; height: 19px; width: 65px;"
        runat="server" Text="&lt;b&gt;PO User:&lt;/b&gt;"></asp:Label>

        <asp:DropDownList ID="locationDropDown" runat="server"
           
           
            style="top: 250px; left: 575px; position: absolute; height: 22px; width: 135px"
            DataSourceID="SqlDataSource2" DataTextField="description"
            DataValueField="pkey"  AutoPostBack="True"
        onselectedindexchanged="locationDropDown_SelectedIndexChanged"
        AppendDataBoundItems="True">
           
        </asp:DropDownList>
       
       
       
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
            ConnectionString="<%$ ConnectionStrings:UPT_DemoConnectionString %>"
            SelectCommand="SELECT pkey as pkey,description as description FROM imtbl_warehouse">
        </asp:SqlDataSource>
       
       
       
        <asp:Label ID="locationLabel"
            style="display:block; top: 250px; left: 505px; position: absolute; height: 19px; width: 66px;"
            runat="server" Text="&lt;b&gt;Location:&lt;/b&gt;"></asp:Label>
    <asp:Label ID="SupplierLabel1"
        style="display:block; top: 420px; left: 201px; position: absolute; height: 17px; width: 58px;"
        runat="server" Text="&lt;b&gt;Vendor:&lt;/b&gt;"></asp:Label>
    <asp:Label ID="SupplierLabel0"
        style="display:block; top: 470px; left: 201px; position: absolute; height: 17px; width: 188px;"
        runat="server" Text="&lt;b&gt;Internal Trailer Cleaning?&lt;/b&gt;"></asp:Label>
    <asp:Label ID="loadLabel"
        style="display:block; top: 470px; left: 520px; position: absolute; height: 17px; width: 57px;"
        runat="server" Text="&lt;b&gt;Load #:&lt;/b&gt;" Visible="False"></asp:Label>
        <asp:TextBox ID="CityTextBox0" runat="server"
           
           
           
           
           
           
           
           
           
           
           
            style="top: 340px; left: 575px; position: absolute; height: 18px; width: 128px" ></asp:TextBox>
        <asp:TextBox ID="zipTextBox" runat="server"
           
           
           
           
           
           
           
           
           
           
           
           
            style="top: 365px; left: 652px; position: absolute; height: 18px; width: 60px" ></asp:TextBox>
    <asp:TextBox ID="addressTextBox" multiline="yes" runat="server"
       
       
       
       
       
           
            style="top: 300px; left: 575px; position: absolute; height: 35px; width: 128px; margin-bottom: 0px;"></asp:TextBox>

   
   
    <asp:TextBox ID="DescriptionTextBox" multiline="yes" runat="server"
       
       
       
       
       
           
            style="top: 300px; left: 260px; position: absolute; height: 85px; width: 128px"></asp:TextBox>

   
   
    <asp:Label ID="Label2"
        style="display:block; top: 300px; left: 504px; position: absolute; height: 21px; width: 67px;"
        runat="server" Text="&lt;b&gt;Ship To Address:&lt;/b&gt;"></asp:Label>

   
       
        <asp:Label ID="locationLabel2"
            style="display:block; top: 340px; left: 534px; position: absolute; height: 17px; width: 37px;"
            runat="server" Text="&lt;b&gt;City:&lt;/b&gt;"></asp:Label>
       
       
       
        <asp:Label ID="locationLabel1"
            style="display:block; top: 365px; left: 625px; position: absolute; height: 17px; width: 27px; right: 314px;"
            runat="server" Text="&lt;b&gt;Zip:&lt;/b&gt;"></asp:Label>
       
       
       
        <asp:TextBox ID="supplierTextBox2" runat="server"
           
           
           
           
           
           
           
           
           
           
           
            style="top: 421px; left: 575px; position: absolute; height: 18px; width: 128px" ></asp:TextBox>

   
       
        <asp:TextBox ID="loadNumberTextBox" runat="server"
           
           
           
           
           
           
           
           
           
           
           
            style="top: 471px; left: 576px; position: absolute; height: 18px; width: 128px"
            Visible="False" ></asp:TextBox>

   
       
        </p>

   
        <asp:DropDownList ID="stateDropDown" runat="server"
           
           
            style="top: 365px; left: 575px; position: absolute; height: 22px; width: 50px"
            DataSourceID="SqlDataSource4" DataTextField="description"
            DataValueField="id"  AutoPostBack="True"
         
        AppendDataBoundItems="True">
           
        </asp:DropDownList>
       
       
       
        <asp:SqlDataSource ID="SqlDataSource4" runat="server"
        ConnectionString="<%$ ConnectionStrings:UPT_DemoConnectionString %>"
        SelectCommand="select id,description from imtbl_state"></asp:SqlDataSource>
       
       
       
        <p>
       
       
       
        <asp:Label ID="locationLabel0"
            style="display:block; top: 365px; left: 525px; position: absolute; height: 19px; width: 43px;"
            runat="server" Text="&lt;b&gt;State:&lt;/b&gt;"></asp:Label>
       
       
       
        </p>

   
    <asp:CheckBox ID="cleaningCheckBox"
        style="display:block; top: 470px; left: 390px; position: absolute; height: 20px; width: 63px;"
        runat="server" oncheckedchanged="cleaningCheckBox_CheckedChanged"
        Text="Yes" AutoPostBack="True" />

   
    <asp:Label ID="SupplierLabel2"
        style="display:block; top: 422px; left: 480px; position: absolute; height: 17px; width: 95px;"
        runat="server" Text="&lt;b&gt;Reference #:&lt;/b&gt;"></asp:Label>

   
   
    <asp:SqlDataSource ID="SqlDataSource5" runat="server"
        ConnectionString="<%$ ConnectionStrings:UPT_DemoConnectionString %>"
       
        SelectCommand="SELECT a.issue_cost AS Cost, a.order_quantity AS qty, b.description, a.order_quantity AS Expr1, a.requested_by FROM dbo.imtbl_po_order AS a INNER JOIN dbo.imtbl_asset AS b ON a.asset = b.pkey WHERE (a.purchase_order &lt;&gt; @location)">
        <SelectParameters>
            <asp:ControlParameter ControlID="locationDropDown" DefaultValue=""
                Name="location" PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource8" runat="server"
        ConnectionString="<%$ ConnectionStrings:UPT_DemoConnectionString %>" SelectCommand="SELECT     a.issue_cost AS Cost, a.order_quantity AS qty, b.description, a.order_quantity AS Expr1, a.requested_by
FROM         imtbl_po_order a INNER JOIN
                      imtbl_asset b ON a.asset = b.pkey
WHERE     (a.purchase_order &lt;&gt; @newentry)">
        <SelectParameters>
            <asp:ControlParameter ControlID="vehicleDropDown" Name="newentry"
                PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>
   
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
           
        <asp:GridView ID="GridView1" runat="server"
    AutoGenerateColumns="True"
        DataSourceID="SqlDataSource10"
        csClass="style1"
        style="top: 580px; left: 150px; position: absolute; height: 103px; width: 700px"
                AllowPaging="True">
       
       
       
    </asp:GridView>
       
       
            <asp:SqlDataSource ID="SqlDataSource10" runat="server"
                ConnectionString="<%$ ConnectionStrings:UPT_DemoConnectionString %>"
               
                SelectCommand="SELECT [description], [unitPrice], [extendedAmount], [vehicleNumber], [poNumber], [qty] FROM [imtbl_templineitem]">
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource9" runat="server"
                ConnectionString="<%$ ConnectionStrings:UPT_DemoConnectionString %>"
                SelectCommand="SELECT [pkey], [description], [unitPrice], [extendedAmount], [vehicleNumber], [poNumber], [qty] FROM [imtbl_templineitem]">
            </asp:SqlDataSource>
       
       
        </ContentTemplate>
         
          <triggers>
        <asp:AsyncPostBackTrigger runat="server" EventName="Click" ControlID="Button1" />
         </triggers>
       
       
    </asp:UpdatePanel>
   
   
   
   
   
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="Data Source=OKCDB01;Initial Catalog=UPT_Demo;Persist Security Info=True;User ID=po_test;Password=mypassword"
        ProviderName="System.Data.SqlClient"
        SelectCommand="SELECT pkey, po_prefix, po_num, po_release_num, purchase_order_type FROM dbo.imtbl_purchase_order WHERE (warehouse = @warehouseid)">
        <SelectParameters>
            <asp:ControlParameter ControlID="locationDropDown" Name="warehouseid"
                PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>

   
                <asp:DropDownList ID="vendorDropDown" runat="server"
                    DataSourceID="SqlDataSource6" DataTextField="description"
        DataValueField="id" Height="22px"
        style="top: 420px; left: 260px; position: absolute; width: 129px">
                </asp:DropDownList>

   
    <HeaderTemplate>
        <table border="1" cellspacing="0" style="Z-INDEX: 101;
         LEFT: 150px;
         POSITION: absolute;  width:590px;
         TOP: 500px" cellpadding="5" align="center"  id="table4" >
          <tr>
          <th>QTY</th>
            <th>DESCRIPTION</th>
            <th>UNIT PRICE</th>
            <th>EXTENDED AMOUNT</th>
             
             <th>VEHICLE NUMBER</th>
             <th>ADD ITEM</th>
          </tr>
      </HeaderTemplate>
      <ItemTemplate>
           
           
          <tr class="style1">
           
            <td class="fontstyle" >
                <asp:TextBox ID="qtyTextBox" runat="server" Width="62px"></asp:TextBox>
              </td>
               <td class="fontstyle1"><asp:TextBox ID="descriptionItemTextBox" runat="server"></asp:TextBox>
                   </td>
            <td class="fontstyle1">
                <asp:TextBox ID="priceTextBox" runat="server" Width="66px"></asp:TextBox>
              </td>            
            <td class="fontstyle1">
                <asp:TextBox ID="extendedTextBox" runat="server" Width="88px"></asp:TextBox>
              </td>
           
            <td class="fontstyle1">
                <asp:DropDownList ID="vehicleDropDown" runat="server"
                    DataSourceID="SqlDataSource7" DataTextField="description"
                    DataValueField="id" Height="22" Width="165" AutoPostBack="True">
                </asp:DropDownList>
               
              </td>
            <td class="fontstyle1">
                <asp:Button ID="Button1" runat="server" Text="Add Item"
                    onclick="Button1_Click" UseSubmitBehavior="True" />
             </td>
           
          </tr>
      </ItemTemplate>

   
    </form>
    </body>
</html>

0
Comment
Question by:soccerman777
2 Comments
 
LVL 22

Accepted Solution

by:
prairiedog earned 500 total points
Comment Utility
Because you didn't rebind your GridView after inserting the new record.
After "cnn.Close()", add "GridView1.DataBind()".
0
 

Author Closing Comment

by:soccerman777
Comment Utility
thanks again
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now