ASP.net 2.0 Gridview with Expanding Panel Rows -- How to build Panel "on the fly"
Asked Answered
A

4

2

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.

Agnostic answered 20/11, 2008 at 21:31 Comment(0)
A
0

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.

Agnostic answered 9/10, 2010 at 1:29 Comment(0)
A
1

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.

Agnostic answered 20/11, 2008 at 21:48 Comment(0)
B
1

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

Bartels answered 9/6, 2010 at 4:13 Comment(0)
M
0

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.

Mielke answered 20/11, 2008 at 21:44 Comment(0)
A
0

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.

Agnostic answered 9/10, 2010 at 1:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.