如何使用jquery和webmethod将数据从sql server绑定到girdview [英] how bind data from sql server to girdview using jquery and webmethod

查看:55
本文介绍了如何使用jquery和webmethod将数据从sql server绑定到girdview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <   asp:GridView     ID   =  grid_projectscredit     runat   =  server    AutoGenerateColumns   =  false   宽度  =  100%  

< span class =code-attribute> ShowHeader = true GridLines = 水平 >
< >
< asp:templatefield >
< itemtemplate >
< div >
< label > < / label >
< / div >
< / itemtemplate >
< / asp:templatefield < span class =code-keyword>>
< asp:templatefield >
< itemtemplate >
< div >
< 输入 类型 = text / >
< / div >
< / itemtemplate >
< / asp:templatefield >
< asp:templatefield >
< itemtemplate >
< div >
< 输入 type = text / >
< / div >
< div > ;
< 输入 < span class =code-attribute> type = text / > ;
< / div >
< / div >
< / itemtemplate >
< / asp:templatefield < span class =code-keyword>>
< asp:templatefield >
< itemtemplate >
< div >
< input type = text / >
< < span class =code-leadattribute> / div >
< div >
< input type = text / >
< / div >
< span class =code-keyword>< div >
< 输入 典型值e = text / >
< / div >
< div >
< 输入 type = text / >
< / div >
< / itemtemplate >
< / asp:templatefield >
< asp:templatefield >
< itemtemplate >
< ; div >
< 输入 类型 = text / >
< / div >
< / itemtemplate >
< / asp:templatefield >
< asp:templatefield >
< itemtemplate >
< div >
< 输入 类型 = text / >
< / div >
< / itemtemplate > ;
< / asp:templatefield >
< asp:templatefield >
< itemtemplate >
< div >
< input type = text readonly / >
< / div >
< / itemtemplate >
< / asp:templatefield >
< / columns >
< / asp:GridView >







如何使用jquery将数据添加到gridview模板?我知道如何绑定服务器端..我需要知道如何使用jquery绑定数据

解决方案

绑定是服务器端。



实际控件将从源代码中获取数据并在控件RenderChildren(HtmlWriter writer)方法中写出html。



如果你想要执行这个客户端,那么你将不得不复制效果。



看一下html数据源绑定在服务器上时页面上的源。创建一个模板和/或将html写入javascript中的var的方法,然后删除现有数据并附加您编写的新行。



An替代方法是使用UpdatePanel。它将允许使用绑定数据源在服务器上呈现网格,但它使用AJAX Web方法将数据写回页面。这是一个更简单的解决方案。



这篇文章应该足以让你开始使用UpdatePanel:



如何使用AJAX UpdatePanel启用部分渲染 [ ^ ]

<asp:GridView ID="grid_projectscredit" runat="server" AutoGenerateColumns="false" Width="100%"

                  ShowHeader="true" GridLines="Horizontal">
        <columns>
            <asp:templatefield >
                <itemtemplate>
                        <div>
                            <label></label>
                        </div>
                </itemtemplate>
            </asp:templatefield>
            <asp:templatefield >
                <itemtemplate>
                        <div>
                            <input  type="text"    />
                        </div>
                </itemtemplate>
            </asp:templatefield>
            <asp:templatefield >
                <itemtemplate>
                        <div>
                            <input type="text"  />
                        </div>
                        <div>
                            <input type="text"  />
                        </div>
                    </div>
                </itemtemplate>
            </asp:templatefield>
            <asp:templatefield >
                <itemtemplate>
                        <div>
                            <input type="text"  />
                        </div>
                        <div>
                            <input type="text"   />
                        </div>
                        <div>
                            <input type="text"   />
                        </div>
                        <div>
                            <input type="text"   />
                        </div>
                </itemtemplate>
            </asp:templatefield>
            <asp:templatefield >
                <itemtemplate>
                    <div>
                        <input type="text"  />
                    </div>
                </itemtemplate>
            </asp:templatefield>
            <asp:templatefield >
                <itemtemplate>
                    <div>
                        <input type="text"  />
                    </div>
                </itemtemplate>
            </asp:templatefield>
            <asp:templatefield >
                <itemtemplate>
                    <div>
                        <input type="text" readonly  />
                    </div>
                </itemtemplate>
            </asp:templatefield>
        </columns>
    </asp:GridView>




How to add data to gridview template using jquery ? i knew how to bind server side.. I need to knw that how to bind data using jquery

解决方案

"Binding" is server side.

The actual control will take the data from the source and write out the html during the controls "RenderChildren(HtmlWriter writer)" method.

If you want to perform this client-side, then you will have to replicate the effect.

Take a look at the html source on the page when the datasource is bound at the server. Either create a template and / or a method that writes the html to a var in javascript, then remove the existing data and append the new rows you have written.

An alternative is to use an UpdatePanel. It will allow the grid to be rendered at the server with the bound datasource, but it using AJAX web methods to write the data back onto the page. It's a much simpler solution.

This article should be enough to get you started with an UpdatePanel:

How to enable partial rendering with the AJAX UpdatePanel[^]


这篇关于如何使用jquery和webmethod将数据从sql server绑定到girdview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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