views:

22

answers:

1

Hi,

As apart of my learning, I want to learn more about the data controls in asp.net. I have used the gridview in situations where it is specifically bound to an sql data source and handles updates and deletes really easily, but I have thought of something that I want to model, however am not sure which control is best to use.

The situation I have thought about is a bank statement. Most bank statements have the transaction name/details in one column, then two columns for debit and credit and then a third column for a running balance.

I have read about using a footer row for insertion records, but I imagine you would not have the same about of columns in a footer (insertion) row. I.e. A transaction would not have a debit and a credit entry field, only an entry field for the amount and a dropdown for debit/credit.

Would the gridview be the best control to model this situation on? Or is there another control that would be best used?

The control won't be talking to a sql datasource, but probably a datatable in the codebehind.

Any thoughts, suggestions, tips would be appreciated.

A: 

A fairly good (but short) answer here: http://stackoverflow.com/questions/139207/repeater-listview-datalist-datagrid-gridview-which-to-choose

For tabular data, use a GridView. For situations where you need more control over the rendering, use a ListView or Repeater.

As for not having the same number of columns... that is really just a matter of styling. If there is no data to display for a particular row's column (such as as insert row in the footer), it can just be blank... if you aren't rendering any borders, then it will look the same as if the row took up all the columns. This is very common.

Bryan
Thank you for pointing me in the right direction. I am now using a listview and its working perfectly.
Mike