Home Search Member List Faq Register Login  
UltimateAjax
Update database with Gridview & Textbox Onblur

Thread Starter: barkster   Started: 01-20-2010 3:13 PM   Replies: 1
 Karamasoft Support Forums » General Discussions » UltimateAjax » Update database with Gridview & Textbox Onblur
 Printable Version    « Previous Thread   Next Thread »
  20 Jan 2010, 3:13 PM
barkster is not online. Last active: 2/1/2016 10:10:20 AM barkster

Top 10 Posts
Joined on 08-07-2008
Posts 33
Update database with Gridview & Textbox Onblur
I've been strugling to get this to work. Does anyone have an example of how to update a database using a gridview and texbox onblur event.  I'm close but just can't get it to work.

Thanks

HTML
<%@ Page Title="" Language="C#" MasterPageFile="~/Intranet.master" AutoEventWireup="true" CodeFile="AcctSpellCheck.aspx.cs" Inherits="AcctSpellCheck" %>
<%@ Register assembly="UltimateSpell" namespace="Karamasoft.WebControls.UltimateSpell" tagprefix="cc1" %>
<%@ Register TagPrefix="cc1" Namespace="Karamasoft.WebControls.UltimateAjax" Assembly="UltimateAjax" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
        <script language="javascript" type="text/javascript">
            function saveRowIndex(rowIndex) {
               // alert(rowIndex);
                DoUltimateCallback('UltimateAjax1',rowIndex);
               // AjaxWithJQuery.SimpleService.NoteChangedRows(rowIndex);
            }
        </script>
    <style type="text/css">
        .style3
        {
            padding-bottom:5px;
        }
        .style4
        {
            text-align:left;
            width: 185px;
        }
        .style1
        {
            text-align:left;
        }      
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="breadcrumb" Runat="Server">
        Accounting | Spell Check
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table style="width: 100%;">
        <tr>
            <td class="style4" valign="top">
            <asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource1"
        DataTextField="UserName2" DataValueField="UserID" Width="185px"
        Height="636px"></asp:ListBox>
    <br />
    <asp:Button ID="bselect" runat="server" Text="Select User" />
    <aspTongue TiedqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:TimeSQLConnectionString2 %>"
       
                    SelectCommand="SELECT [UserName2], [UserID] FROM [LoginTable] WHERE ([active] = @active) ORDER BY [UserName2]">
        <SelectParameters>
            <aspStick out tonguearameter DefaultValue="True" Name="active" Type="Boolean" />
        </SelectParameters>
    </aspTongue TiedqlDataSource>

            </td>
            <td class="style1" valign="top" width="100%">
            <cc1:UltimateAjax id="UltimateAjax1" runat="server" Width="100%">
                <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2"
                    AutoGenerateColumns="False" onrowcreated="GridView1_RowCreated"
                    DataKeyNames="TimeID" Width="100%">
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:TextBox ID="TextBox1" onblur='<%# AttachFunction(Container.DataItemIndex) %>' runat="server" Text='<%# Bind("Description") %>' Width="95%" class="style3" Rows="2" TextMode="MultiLine" ></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <cc1:UltimateSpell id="UltimateSpell1" runat="server" IgnoreWordsInUpperCase="False"
                    SpellAsYouType="True" ShowSpellButton="False" MisspelledWordStyle-BackColor="#FFFF66" ShowOptions="True">
<MisspelledWordStyle Font-Bold="True" ForeColor="#FF0000"></MisspelledWordStyle>

<SpellButton ButtonType="Button" Text="Spell Check" CausesValidation="True" ImageUrl="" ImageAlign="AbsMiddle"></SpellButton>
                </cc1:UltimateSpell>
                </cc1:UltimateAjax>
                <br />
                <aspTongue TiedqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TimeSQLConnectionString2 %>"
                    SelectCommand="SELECT [TimeID],[Description] FROM [BillableTimesheet] WHERE (([UserID] = @UserID) AND ([Exported] = @Exported))">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ListBox1" DefaultValue="-1" Name="UserID"
                            PropertyName="SelectedValue" Type="Int32" />
                        <aspStick out tonguearameter DefaultValue="False" Name="Exported" Type="Boolean" />
                    </SelectParameters>
                </aspTongue TiedqlDataSource>
                <br />
           
            </td>
        </tr>
        </table>
    </asp:Content>

c# code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AcctSpellCheck : System.Web.UI.Page
{
    private void InitializeComponent()
    {
        this.UltimateAjax1.Callback += new Karamasoft.WebControls.UltimateAjax.UltimateAjax.CallbackEventHandler(this.UltimateAjax1_Callback);

    }
    private void UltimateAjax1_Callback(object sender, Karamasoft.WebControls.UltimateAjax.CallbackEventArgs e)
    {
        //throws error: Microsoft JScript runtime error: 'uab0' is null or not an object
       
        //looking to get use the id to get the textbox value and update database here.
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        //TextBox tb = (TextBox)e.Row.FindControl("Textbox1");
        //tb.Attributes.Add("onblur", "jalert('"+tb.Text+"');");
    }
     protected string AttachFunction(int rowIndex)
        {
            string function = "saveRowIndex(";
            return function + rowIndex + ")";
        }
}


  
  20 Jan 2010, 8:58 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Update database with Gridview & Textbox Onblur
If all you need to pass is the rowIndex to the server-side during page callback, you can try placing the UltimateAjax control separately before closing your asp:Content element instead of wrapping it around the GridView and UltimateSpell components as follows:

...
<cc1:UltimateAjax id="UltimateAjax1" runat="server" Width="100%">
</cc1:UltimateAjax>
</asp:Content>

  
 Page 1 of 1 (2 items)
Karamasoft Support Forums » General Discussions » UltimateAjax » Update database with Gridview & Textbox Onblur

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2018 Karamasoft LLC. All rights reserved.