In asp.net , what is the difference between gridview and repeater controls - c#

I have worked with both the controls for simple application development . Both almost do the same functionality. What is the difference between them ?

There is a table here that compares the data bound server controls:
http://weblogs.asp.net/anasghanem/archive/2008/09/06/comparing-listview-with-gridview-datalist-and-repeater.aspx

GridView always renders as a grid. Repeater allows you to create your own template layout. For instance, you can put things in divs. GridView also has a much more rich object model, while repeater is rather simplistic.
Yes, you can achieve similar results with both, but they are nowhere near the same thing.

Both these controls are Data-Bound Web Server control.
GridView : It displays data as a table and has ability to preform sort, paging,edit and delete a record.
Repeater : has fewer templates then GridView. It renders a read-only list from the datasource.

Related

Asp.net data listing

I want to list data with repeater from database on a server. There are nearly 5000 data in the database. When listing this data with repeater, the page loads a bit late. How can I quickly list data?
Thanks..
Simple: don't try to display so much data in one list.
No user is going to scroll through 5000+ records to find the one they want.
Use paging, and provide options for the user to filter the returned data.
NB: Whilst you can add paging support to the Repeater control, it's not supported by default. You would probably have better luck using the ListView control instead, combined with a DataPager control.

How can I create/delete a table row with form controls using AJAX?

I have a table that has several fixed rows that contain user controls that have their own Update panels. I need to be able to create new rows within this table, each column of which contains a TextBox control. I don't want to just wrap the whole table in an Update Panel for obvious reasons, but want to be able to create/delete the new row(s) without a full postback and have the TextBox controls registered/de-registered to/from the page, without having to rebuild the entire table.
Any ideas how/if this can be done?
It can be done using a client-side approach, such as building the UI with JavaScript templating or an MVVM framework. You could also use a ListView that can be easily templated to render the initial shell, and additional rows can be added with JavaScript.
Or, wrap the whole table in one UpdatePanel.

GridView - add formatted child rows from Ajax call that matches the rendered grid

I have an asp.net webforms site with a rather large GridView. The GridView is rendered from a filtered list of data objects.
Some of the data objects have children of the same type.
In my GridView, I'm initially only showing the parent objects. I want to be able to expand the parent to show the child objects, via an Ajax call, and insert the new rows under the parent.
The catch is, they need to follow the same formatting and rendering rules as the parent, and fit in with all the rest of the existing rows. This means that all columns of the new child needs to fit in the columns of the rest of the rendered grid.
I would also like to re-use the existing GridView rendering methods if possible, so I don't have to maintain duplicate code that essentially does the same thing.
I can easily use the DynamicPopulateExtender from the AjaxControlToolkit to call a web service to get the child rows, but that wouldn't easily give me the rendered and formatted HTML that would fit into the already rendered GridView table.
Is there a way to get this to work properly, or is there a different way I should approach this?
Make your Ajax calls and insert the data with jQuery perhaps using a templating engine like jsRender to merge the data. Use the same css classes for the gridview and template to keep the uniform look you want.

Inserting , updating and deleting of Data

I want to make a control that show list of bounded data like in grid view but I want to be able to insert new record from the same control
what is the best asp.net control I can use to do that (GridView , FormView or DetailsView)? and why?
Thanks in Advance
You can do that with all three. If you want to know how, there are some good tutorials on the official ASP.NET website, here.
The choice between them is a formatting/layout decision. A GridView produces a table, showing multiple records, while a DetailsView shows one at a time. A FormView lets you display the data however you want, but required much more effort, since you have to provide the HTML.

C# gridview nested in repeater update

My current situation is to display an unknown number of Plantypes and within those Plantypes display a list of Participants(also unknown number), the participants have a textbox and a dropdown that is editable (you can't edit the individual rows, there is one update that does a bit of validation then updates all rows.)
I currently have a gridview nested withing a repeater, the repeater displays the Plan in a label and OnItemDataBound I call a method to populate the gridviews. It looks great, but I can't figure out how to save all the data at once. I'm not opposed to handling this a different way, as in loose the gridview and or repeater, if someone has a better idea.
This is C# and framework 2.0...there is no sorting or paging on the gridviews...just some links and the fields to update.
thanks in advance,
Padawan
HTTP is stateless. Since a user physically can only update one record at a time you should implement some way to save as the user goes. This can be a simple as having a row focus and row blur events and do the saves using AJAX on blur(unfocus). Maybe make is modal as they edit so they cannot leave the page without saving.

Categories

Resources