我如何获取我的obout网格以进行更新 [英] How do I get my obout grid to update

查看:79
本文介绍了我如何获取我的obout网格以进行更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到解决问题的方法,但无济于事.
我有带有客户端脚本的obut网格,可以拉出一个窗口表单来编辑或添加新数据.添加和删​​除都可以正常工作.但是我无法使更新生效.

工作测试是 demo.23records.net/test.aspx [ ^ ]

我有一个警报显示我正在向其发送正确的数据,但update命令不会更新网格或数据库.

使用Sql Server 2008,asp.net 4.0和Sql数据源更新命令.

我需要做什么才能使更新生效?

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?

<%@ 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>

推荐答案

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 =" runat 服务器" 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 >
ConnectionStrings:db23ConnectionString %>" SelectCommand="SELECT DISTINCT a_name FROM [Artist]" /> </form> </body> </html>




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

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


这篇关于我如何获取我的obout网格以进行更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆