使用SP返回的不同标题创建动态框(div) [英] Creating dynamic boxes (divs) with different titles returned by SP

查看:165
本文介绍了使用SP返回的不同标题创建动态框(div)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望您在新年开始时都能做得很好。



我是初学者开发人员。我正在开发一个网站。我有几个div,它组成了通过jquery portlet增强的可拖动框。请参阅下面的代码(html)。

 < div class =portlet> 
< div class =portlet-header>类别A< / div>
< div class =portlet-content>
< / div>
< / div>

< div class =portlet>
< div class =portlet-header>类别B< / div>
< div class =portlet-content>
< / div>
< / div>

我还有一个返回类别列表的数据库开发人员的存储过程。根据用户选择,类别列表可以有所不同。
所以我必须动态创建这些框。 SP返回的每个类别应替换类别A 类别B ,等等。因为我不知道SP返回的类别的数量,只是硬编码那些div。我的问题是怎么回事?我如何实现这一点?



我必须在VS 2010中使用VB.net。数据库位于SQL Server 2008中。
这么多的细节和你的详细信息可以在您的回复,因为我是一个初学者。谢谢ssssssssss。

解决方案

确定,所以我这样做的方式是,你在网站上设置一个通用处理程序来查询数据库为您的类别。你将需要在页面上打印这些数据作为JSON,所以jquery可以很容易地理解它,然后在您的网页,你想显示的信息,使用jquery的getAjax函数来调用你的通用处理程序,然后循环通过类别你的处理程序



你也可以在asp.net上使用ajax和一个中继器来做到这一点,只需在页面中添加一个中继器,设置ItemTemplate div设计,并将中继器挂在你的SP代码中。



如果你对这部分内容有疑问,只要评论,我会尽力帮助。 p>

Wish you all are doing fine at the start of a new year

I am a beginner developer. I am developing a website. I have few divs which made up dragable boxes enhanced by jquery portlets. Please see the codes below.(html).

    <div class="portlet">
    <div class="portlet-header"> Category A </div>
    <div class="portlet-content">   
    </div>
    </div>

    <div class="portlet">
    <div class="portlet-header"> Category B </div>
    <div class="portlet-content">   
    </div>
    </div>

I also have a stored procedure from the database developer that return the list of categories. Depending on the user selection, the list of categories can vary. So i have to dynamically create those Boxes. Each categories returned by the SP should replace Category A, Category B, and so on. As i can't know the number of categories returned by the SP i just hard coded those divs. My question is simply how ? How can i achieve this?

I have to be using VB.net in VS 2010. The database is in SQL server 2008. THanks so muchhhhhh and pls have as much detail as you can in your reply as i am a beginner. Thankssssssssssss.

解决方案

OK, so the way I do this is, you setup a generic handler on your web site to query the database for your categories. You will need to print this data on the page as JSON so jquery can easily understand it, then on your web page that you want to display the info, use jquery's getAjax function to call your generic handler, and then loop through the categories your handler returns creating a div for each.

You can also do this with ajax and a repeater on asp.net, simply add a repeater to the page, setup the ItemTemplate with your div design, and hook the repeater to your SP in the code behind.

If you have questions about parts of this, just comment and I will try to help.

这篇关于使用SP返回的不同标题创建动态框(div)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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