Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gridview or table? 1

Status
Not open for further replies.

Trusts

Programmer
Joined
Feb 23, 2005
Messages
268
Location
US
Hi,

I am creating a page for input. The number of rows is not known ahead of time (although the columns are fully known)

I would need to either use a gridview, but unbound, if possible.

Or I could use a asp:table.

For either, the user would click a button to add new blank rows (inside the cells are textboxes or dropdowns).

I can get this to work easily with a table, but the contract I'm - they prefer I use gridviews. But I don't think this is possible with a gridview? I could bind the gridview to the table, but all I want are blank rows. I've read that using a footer template you can create a new blank row for entry, but can I create 10 at once with a gridview?

With a table I can, with code, add any number of rows, name each row and cell uniquely, have each cell contain the correct control.

Opinions? Should I try to follow the marching orders and somehow use a gridview for this? Can it be done?

Thanks,
KB
 
You can do this with a GridView as well (to add 10 rows you could simply add 10 rows to your data source and then rebind). The GridView has several advantages over a table (e.g. built-in paging, sorting etc) but from your above description it doesn't look as though you need them. In your case, I'd just go with the solution you are most comfortable with as they will both work.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Adding ten rows to the datasource - I assume this means the underlying table, not some in between dataset or somesuch. That seems problematic. I could see literally adding the physical rows and then the user gets distracted with something else and they close the browser. Now the table has 10 blank rows which are put to no use.

Does that make sense? At least with table if they close out, nothing is put in the database. The data is gone, but not a problem on the tech people end. They would have to click a Submit button to commit, and then valid rows are written.
 
It means adding them to the datasource that the control is bound to. Unless you specifically write those rows back to the database, then if the user closes the browser it won't affect the database as the object won't write the changes back.

Both methods you've listed will work in the same way, will only be written once to the database when you specifically tell it to, and will only differ by the actual control that displays the rows.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks ca8msm,

If I use the gridview I have a SQLDataSource control. How does that hold these uncommitted rows. I don't see a way to do that??

Thanks,
KB
 
I'm not sure as I tend to stay away from objects such as the SQLDataSource. With a DataTable, you would simply call the Rows.Add method so I assume there will be something similar you can do.

Alternativly, you could add the rows directly to the GridView like this:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top