I have a aspx page which has no problem to show multiple records from a db table as selected items in list box control ASP.net 2.0. After user change their selection in list box, how can I effectively and correctly post the user selections back to db table?

Is DELETE current records and INSERT new records a better solution? How can I roll back transaction correctly if something wrong happen when executing the sql commands?

Please give your suggestion.

Thanks in advance.


You should use dataset features

like RowState.added, modified , deleted or unchanged

to know the status of each dataset's datatable row

Mohammed Yousuf uddin

Hi Mohammed,

Would you give me example of using rowstate? This is new to me.



Hi there

Apolozise for the delay. U might have fixed ur soltion by this time. but this one for the reference for and other new-bees.

dim pJobsProfile as new JobsProfileDS 'dataset

For Each drwJobsProfile In pJobsProfile.JobProfileInfo
                    dsJobsProfile = New JobsProfileDS
                    Select Case drwJobsProfile.RowState
                        Case DataRowState.Added
                            drwJobsProfile.CreatedBy = objStates.UserName
                            InsertData(dsJobsProfile, objTrans)
                        Case DataRowState.Modified
                            UpdateData(dsJobsProfile, objTrans)
                        Case DataRowState.Deleted
                            DeleteData(dsJobsProfile, objTrans)
                    End Select

Mohammed Yousuf uddin
Software Developer

This article has been dead for over six months. Start a new discussion instead.