Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have tried to find a solution to my issue with no avail.
I have my obout grid with client side scripts to pull up a window form to edit or add new data. The add works fine as does delete. However I cannot get the update to work.

The working test is demo.23records.net/test.aspx[^]

I have an alert put in to show that I am sending it the correct data but the update command does not update the grid or the database.

Using Sql server 2008, asp.net 4.0 and the Sql data source update command.

What do I need to do to get my update to work?

C#
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
<%@ Register TagPrefix="obout" Namespace="Obout.Grid" Assembly="obout_Grid_NET" %>
<%@ Register TagPrefix="obout" Namespace="Obout.SuperForm" Assembly="obout_SuperForm" %>
<%@ Register TagPrefix="owd" Namespace="OboutInc.Window" Assembly="obout_Window_NET" %>
<%@ Register TagPrefix="obout" Namespace="Obout.Interface" Assembly="obout_Interface" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html>
	<head>
		<title>Test</title>
        <style type="text/css">
			.tdText {
				font:11px Verdana;
				color:#333333;
			}
			.option2{
				font:11px Verdana;
				color:#0033cc;				
				padding-left:4px;
				padding-right:4px;
			}
			a {
				font:11px Verdana;
				color:#315686;
				text-decoration:underline;
			}

			a:hover {
				color:crimson;
			}
			.super-form {
                margin: 12px;
            }
        
            .ob_fC table td {
                white-space: normal !important;
            }
        
            .command-row .ob_fRwF {
                padding-left: 50px !important;
            }
		</style>
		<script type="text/javascript">
		    function Grid1_ClientEdit(sender, record) {
		        Window1.Open();

		        document.getElementById('id').value = record.id;
		        SuperForm1_a_name.value(record.name);
		        SuperForm1_title.value(record.title);
		        SuperForm1_pic.value(record.pic);

		        return false;
		    }


		    function Grid1_ClientAdd(sender, record) 
            {

		        Window1.Open();

		        document.getElementById('id').value = 0;
		        SuperForm1_a_name.value('');
		        SuperForm1_title.value('');
		        SuperForm1_pic.value('');

		        return false;
		    }

		    function saveChanges() {
		        Window1.Close();

		        var aid = document.getElementById('id').value;

		        var data = new Object();
		        
		        data.name = SuperForm1_a_name.value();
		        data.title = SuperForm1_title.value();
		        data.pic = SuperForm1_pic.value();

		        if (aid != 0) 
                {
                    data.id = aid;
                    Grid1.executeUpdate(data);

                    // Only here to show that it is spitting out the right data.
                    alert("ID: " + data.id + "\nArtist: " + data.name + "\nAlbum Title:  " + data.title + "\nAlbum Picture:  " + data.pic);
                    
		        }
		        else 
                {
		            Grid1.executeInsert(data);
		        }
		    }

		    function cancelChanges() {
		        Window1.Close();
		    }

    </script>	
	</head>
	<body>	
		<form id="Form2" runat="server">
            <span id="WindowPositionHelper"></span>
            <obout:Grid  runat="server" ID="Grid1" AutoGenerateColumns="false" DataKeyNames="id"
                DataSourceID="SqlDataSource1" Serialize="False">
                <Columns>
			        <obout:Column ID="Column1" DataField="id" Visible="False" Width="150" ReadOnly="True" HeaderText="ID" />
                    <obout:Column ID="Column2" DataField="name" Width="200" HeaderText="Artist" />
                    <obout:Column ID="Column3" DataField="title" Width="200" HeaderText="Album Title" />
                    <obout:Column ID="Column4" DataField="pic" Width="200" HeaderText="Album Picture" />  
                    <obout:Column ID="Column14" HeaderText="EDIT" Width="150" AllowEdit="true" AllowDelete="true" />                 
		        </Columns>		
		        <ClientSideEvents OnBeforeClientEdit="Grid1_ClientEdit"  önBeforeClientAdd="Grid1_ClientAdd" ExposeSender="true" />
            </obout:Grid>

            <owd:Window ID="Window1"  runat="server" IsModal="true" ShowCloseButton="true" Status=""
                RelativeElementID="WindowPositionHelper" Top="-25" Left="100" Height="370" Width="551" VisibleOnLoad="false" StyleFolder="Styles/default"
                Title="Add / Edit Record">
                    <input type="hidden" id="id"  />
                    <div class="super-form">
                        <obout:SuperForm ID="SuperForm1"  runat="server"
                            AutoGenerateRows="false"
                            AutoGenerateInsertButton ="false"
                            AutoGenerateEditButton="false"
                            AutoGenerateDeleteButton="false"                        
                            DataKeyNames="id" DefaultMode="Insert" Width="525">
                            <Fields>
                                <obout:DropDownListField DataField="a_name" HeaderText="Artist" FieldSetID="FieldSet1" DataSourceID="SqlDataSource3" />
                                <obout:BoundField DataField="title" HeaderText="Album Title" FieldSetID="FieldSet1" />
                                <obout:BoundField DataField="pic" HeaderText="Album Pic" FieldSetID="FieldSet1" />
                                <obout:TemplateField FieldSetID="FieldSet4">
                                    <EditItemTemplate>
                                        <obout:OboutButton ID="OboutButton1"  runat="server" Text="Save"  önClientClick="saveChanges(); return false;" Width="75" />
                                        <obout:OboutButton ID="OboutButton2"  runat="server" Text="Cancel"  önClientClick="cancelChanges(); return false;" Width="75" />
                                    </EditItemTemplate>
                                </obout:TemplateField>
                            </Fields>
                            <FieldSets>
                                <obout:FieldSetRow>
                                    <obout:FieldSet ID="FieldSet1" Title="Album Information" />
                                </obout:FieldSetRow>
                                <obout:FieldSetRow>
                                    <obout:FieldSet ID="FieldSet4" ColumnSpan="2" CssClass="command-row" />
                                </obout:FieldSetRow>
                            </FieldSets>
                            <CommandRowStyle HorizontalAlign="Center"></CommandRowStyle>
                            <FieldHeaderStyle HorizontalAlign="Right" Width="100px"></FieldHeaderStyle>
                            <PagerStyle HorizontalAlign="Center"></PagerStyle>
                        </obout:SuperForm>
                    </div>
            </owd:Window>
           
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:db23ConnectionString %>" 
                SelectCommand="SELECT * FROM [albums]"
                UpdateCommand="UPDATE Orders SET name=@name, title=@title, pic=@pic WHERE id=@id"
                InsertCommand="INSERT INTO albums (name, title, pic) VALUES (@name, @title, @pic)" 
                DeleteCommand="DELETE FROM albums WHERE id=@id">
                <UpdateParameters>
                    <asp:Parameter Name="name" Type="String" />
                    <asp:Parameter Name="title" Type="String" />
                    <asp:Parameter Name="pic" Type="String" />
                    <asp:Parameter Name="id" Type="Int32" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="name" Type="String" />
                    <asp:Parameter Name="title" Type="String" />
                    <asp:Parameter Name="pic" Type="String" />
                </InsertParameters>
                <DeleteParameters>
                    <asp:Parameter Name="id" Type="Int32" />
                </DeleteParameters>
            </asp:SqlDataSource>

            <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                ConnectionString="<%$ ConnectionStrings:db23ConnectionString %>" 
                SelectCommand="SELECT DISTINCT a_name FROM [Artist]" />          

		</form>
	</body>
</html>
Posted
Comments
BillWoodruff 3-Feb-12 0:14am    
Why aren't you asking the company that makes the Obout control these questions ?

http://www.obout.com/inc/support.aspx
Pawen 3-Feb-12 0:23am    
I have asked there as well. And the issue was the same with there tools as with regular asp.net tools. So the question is valid for obout and asp.net as both would use the same code. As far as the sql datasource and the client side code.
BillWoodruff 3-Feb-12 11:18am    
Then I suggest you re-write your question, and eliminate all references to "obout" specific controls.
RDBurmon 4-Feb-12 4:38am    
I agreed with you. Pawan you have to do this to resolve this question . revert back with the changes as Bill suggest.
Wonde Tadesse 5-Feb-12 15:19pm    
Still you need to check with obout support site.

1 solution

Hi,

Download their grid suite with examples included and see ow they are doing insert/update using window and superform...
Here[^] it is..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900