Subject: Two controls with tabular data - which ones?
Posted By: pettrer Post Date: 4/4/2006 3:10:43 PM
Hi,

I'd like to have a "table" that can get new rows, delete rows, and overall be editable. When this table is updated (via postback I guess) another table on the same page should be updated as well. Among other things, a sum for money fields in some of the rows should be updated, and the first table's money fields that belong to the same name should be added up (see below). I made a similar thing with Asp and Javascript via Innertable code, but I want to do it the .Net way if possible.

This is what I mean:

Table_1

Col1       Col2        Col3

Name1  Address1 Money1

Name2  Address2  Money2

Name2 Address3  Money3

Table_2

Col1      Col2                Col3

Name1 Somethingelse1  MoneySum

Name2+3 Somethingelse2+3 MoneySum2+3

What controls should I use? I first thought of grid views, but they don't support Delete, so I don't know what to do. I guess AJAX could be used as well, but if the postback isn't really slow, I'd like this instead.

I use Asp.Net 2.0, VB, and VWD Express (which is great, BTW!).

Thanks in advance for any help solving this (at least to me) complex task!

Pettrer


Coding is indeed a nine-to-five job; nine pm to five am.
Reply By: Imar Reply Date: 4/4/2006 3:15:36 PM
Hi Pettrer,

quote:
I first thought of grid views, but they don't support Delete, so I don't know what to do.
What makes you think the GridView cannot delete? If the underlying data source supports deleting (e.g. e DeleteMethod for an ObjectDataSource or a Delete query for a SqlDataSource), deleting *is* supported in GridViews.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: The Order Of Death by Public Image Ltd. (Track 8 from the album: This Is What You Want... This Is What You Get) What's This?
Reply By: pettrer Reply Date: 4/5/2006 3:12:57 AM
Sorry, I was a bit confused there... What I should have written is that GridView does not support Add row (according to Beginning Asp.Net 2.0, p. 244).

Another thing: On the GridView's flyout menu, why don't I always get Enable Deletion and Enable Selection? (Couldn't find any info on this matter in the book.)

Thanks for replying!

Pettrer

BTW - Cool MP3-thing in your signature!

Coding is indeed a nine-to-five job; nine pm to five am.
Reply By: Imar Reply Date: 4/5/2006 1:00:14 PM
Right, I see. That is correct.

In most circumstances, you can use a DetailsView to allow a user to insert new records, or edit more complex data structures (with custom templates for stuff like Calendars and so on).

Alternatively, you could create a custom class, say Content, with Get, Insert, List and Update methods. Then you can use an ObjectDataSource and use that for data access. With a custom class, it's easier to create a custom InsertUpdate page that allows you to manage your data.

You won't get these options if the underlying data source control doesn't support these features. So, when your SqlDataSource or ObjectDataSource doesn't have code to delete records, the GridView doesn't have the option on the Smart Task pane. However, you can still enable deleting for the GridView through the Properties grid for the control

I am glad you like my little unuseless Chindogu project.... ;-)

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004

Go to topic 42438

Return to index page 322
Return to index page 321
Return to index page 320
Return to index page 319
Return to index page 318
Return to index page 317
Return to index page 316
Return to index page 315
Return to index page 314
Return to index page 313