Hi,

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.

wsee

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.

Thanks,

wsee

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
                            dsJobsProfile.JobProfileInfo.ImportRow(drwJobsProfile)
                            InsertData(dsJobsProfile, objTrans)
                            dsJobsProfile.Clear()
                        Case DataRowState.Modified
                            dsJobsProfile.JobProfileInfo.ImportRow(drwJobsProfile)
                            UpdateData(dsJobsProfile, objTrans)
                            dsJobsProfile.Clear()
                        Case DataRowState.Deleted
                            dsJobsProfile.JobProfileInfo.ImportRow(drwJobsProfile)
                            DeleteData(dsJobsProfile, objTrans)
                            dsJobsProfile.Clear()
                    End Select

Mohammed Yousuf uddin
Software Developer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.