Expandable/Collapsible Gridview Rows without using Nested Gridviews? - asp.net

I need to add an expandable feature to my gridview and I am not quite sure if the tutorials I am finding online quite cover what I'm looking for. We have a gridview that is populated with the results of a SQL query. These results are sorted by "expiration date," with all expired records moved to the top and greyed out. We want to collapse all expired records to make it cleaner, visibility-wise. Does anyone have any tips on how to approach this? Most of what I am finding involves a nested gridview, however I'm not sure if that pertains to this project.

If you are using jQuery in your web page this is simple. Add a css class to those rows you want to hide. And just call the .hide() on them.
$('.greyedout').hide();
Below is a sample which shows hiding of rows is possible. Hope it explains the basic idea to you.
http://jsfiddle.net/deostroll/LVyvR/embedded/result/

Related

Multiple ListBoxes and insert form

I want to create multiple listboxes when you select the first it does a database query which gets a list for the second list box and it carries on for the third and so on. Beside each list box is a form to insert an entry for that list is there an article or video on how to do this. Some ajax might be needed to do what I want Im not really sure what to do I can't find an article on this. does anyone have any links for me
You want the functionality like what would be done in Cascading DropDownList except that your control is ListBox.
See samples and Ideas there, it could be helpful.

asp.net datagrid sorting

I have a datagrid that is displaying data that is being returned from a stored procedure. That works fine. The problem is that I want to do sorting. I know that there is sorting functionality in the grid, however, I don't want to go back to the server and get a new set of data. What I want to do is just re-sort the data that is already being displayed.
Anyone have any ideas on how that is done?
Thanks!
UPDATE
Basically, I couldn't not find an easy solution to this issue. I tried updating my dataGrid to a gridView control and even that (for my particular issue) was difficult. I wound up un-doing all the changes and just adding another grid that had just the data I wanted for the requirement.
If anyone else has an issue like this I would recommend taking it out of a datagrid and writing it in jQuery. I could of written a table that had the data I wanted (and fully sortable using a plug-in mentioned below) in 15 minutes compared to the hours I spent trying to jam a square peg into a round hole.
One thing you can do is save the current result set into the users session, provided it isn't that large. You can then use the build in sorting capabilities of the DataGrid without dealing with a round trip to the database.
You will make a trip back to the server, but often the trip to the web server and back is far faster than the trip that involves the database.
It sounds like what you're wanting is to do the sorting on the client-side (the built-in grid sorting is server-side, and it sounds like you don't want the round trip). If you're using jQuery, there are some very easy plugins to handle sorting a on the client. For example, with the tablesorter plugin (http://tablesorter.com/docs/), you can do this with one line of code:
jQuery(".gv").tablesorter();
Where gv is a css class used for all my tables (GridView controls in an ASP.net application).
You'll need to make sure that your DataGrid is rending a <thead> and <tbody>, see related question for a Javascript way to add these, or you can do it from the codebehind in the PreRender event: ASP.NET 2.0 - DataGrid with tbody / thead

how to get started with using `GridView` in ASP.net?

How to get started with using GridView in ASP.net?
grid view is pretty slick especially in asp.net. You can check all the gridview tutorials on ASP DATA TUTORIALS.. it is the perfect place to start learning asp.net. If you don't want to learn then you can always add a sql database, insert a grid view and connect it to the data base via a datasource. Then you can play around with it. However i will strongly recommend those tutorials as they contain all tips and tricks you want to know. You can ask more questions here, i will be glad to answer.
And I inherited from the GridView to create the GridViewTree - a multi-column treeview server control. So reviewing this might give you some other ideas.
It can be found here.
Well, I have a few blog posts on the GridView:
Multiple Row Selections with CheckBoxes.
Checking All Rows Using Client-Side Script.
Attaching upload files to a record.
Sort Column Arrow Performance.
How to Work With a GridView Row in JavaScript.
All can be found here.

Can database fields be dragged and dropped (as textboxes, not a gridview) into an ASP.Net form?

In VisualStudio, when you drag and drop a table or an individual column from a data connection in server explorer, a gridview is created.
What I want to be able to do is drag and drop the columns to make a quick and dirty detail form to display an individual record. Is this possible in any way?
An even better way to do this would be via a custom T4 or LLBLGen template but I have no clue how to do this.
Any other suggested approaches?
UPDATE: A DetailsView is the type of thing I am looking for, in that you can select a data source and the specific columns you want, but I'd like to be able to have manual control of the layout and formatting after the initial drag and drop.
I suggest binding a DetailsView to the table using a data source (SqlDataSource) instead. You might find these tutorials, especially this one helpful.
In response to your update, have a look at the FormView control. It gives you complete control of the layout using templated sections.
There appears to be literally no way to do this in VS that I have come across.

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

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.
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.
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
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.
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.

Resources