具有扩展面板行的 ASP.net 2.0 Gridview - 如何“即时”构建面板

发布于 2024-07-09 02:30:24 字数 303 浏览 5 评论 0原文

我目前正在构建一个具有可扩展行的 Gridview。 每行包含一个动态创建的表单元素面板。 现在,我有一个 javascript 函数,当在 Gridview 行上单击图像时,该函数会展开(或者在我的情况下,使其可见)面板。

我的问题是......有没有更有效的方法来做到这一点。 一种方法可以在用户单击“展开”按钮时简单地创建带有充满文本框和下拉列表的面板的行,而不是在数据绑定时首先提取所有数据并构建每个新行?”

有没有 喜欢通过这样做来限制服务器调用,而不是我当前的做法,循环遍历每一行并使用表单元素创建一个新面板并将其插入到隐藏的行中。

I'm currently building a Gridview that has expandable rows. Each row contains a dynamically created Panel of Form elements. Right now, I have a javascript function that expands (or in my case, makes visible) the panel when an Image is clicked on the Gridview row.

My question is... is there a more efficient way of doing this. Instead of pulling all my data to begin with and building each new row as I Databind, is there a way to simple create the row with the Panel full of textboxes and dropdownlists on the fly when the user clicks the Expand button?"

I'd like to limit the server calls by doing it that way instead of how I'm currently doing it, looping through every row and creating a new panel with form elements and inserting that into a row that is hidden.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

浅笑依然 2024-07-16 02:30:24

实际上,它的性能并不差,因为我原来的 SQL 查询可以填充每一行,而且我已经在 Gridview 上启用了分页。 我只是想知道它们是否可以使用 PageMethods 或某种 JSON/AJAX 解决方案即时构建。 我没看到任何东西,但是...值得尝试寻找它。

Actually, it isn't performing badly since my original SQL query can populate every single row and I have enabled paging on the Gridview. I'm just wondering if they can be built on the fly using PageMethods or some sort of JSON/AJAX solution. I haven't seen anything, but... worth a try in searching for it.

电影里的梦 2024-07-16 02:30:24

您可以重写 RowdataBound 事件,然后根据单元格中的数据添加所需的任何控件。

http://msdn.microsoft。 com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

you can override the RowdataBound event, and than add whatever controls you want based on what data goes in the cell.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

你又不是我 2024-07-16 02:30:24

个人尝试动态创建数据很可能会导致用户体验变慢。

当我做像你所描述的那样的事情时,我通常使用中继器,这样我就可以做一个模板布局,它可以立即简单地定义所有需要的元素,并处理绑定操作。

否则,我想你的方式不会执行得太慢。

Personally trying to create the data on the fly would most likely result in a slower user experience.

When I do things like what you are describing I typically use Repeaters, that way I can do a template layout that simply defines all of the needed elements right away, and it handles the binding actions.

Otherwise, I would imagine that your way isn't performing too slowly as it is.

岛歌少女 2024-07-16 02:30:24

最近实际上将其用于返回表单结构的 AJAX 处理程序。 它是按需的,并且运行良好。 只需通过 jQuery 调用 $ajax,返回 HTML 结构,注入 DIV 即可。 这对实际功能有点限制,所以要小心。

Actually worked this recently into an AJAX Handler returning the form structure. It's on demand, and works well. Simply call $ajax via jQuery, return an HTML structure, inject into DIV. It's a bit limiting on actual functionality, so be careful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文