Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / October 2004

Tip: Looking for answers? Try searching our database.

How to do a multiple select and update in a datagrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wolffang - 23 Oct 2004 21:21 GMT
Using Visual studio.net VB

I have a datagrid that brings records from a stored procedure.

Be selecting multiple datarows using a checkbox.
All i want to do is update a field called 'Active' datatype bit from 0 to 1
for all those records that have been selected with the checkbox and mark
another field 'User' with the name of the user who selected these items when
a update button is clicked.

checkbox needs to be disabled if the record of 'Active' is 1

any solutions out there???
irene - 27 Oct 2004 20:50 GMT
You can do a batch update.
something like:

 Dim dg As DataGridItem
           Dim ck As CheckBox
           Dim UserID As Label
         
           For Each dg In yourdatagrid.Items
               ck = dg.FindControl("yourcheckboxname")
                UserID = dg.FindControl("yourdatakeyfield")

               If ck.Checked = True Then
                   UpdateUserHistory(UserID.Text, 1)
               Else
                   UpdateUserHistory(UserID.Text, 0)
               End If

           Next
       
and then you can define the function on UpdateUserHistory...

HTH,

Irene

> Using Visual studio.net VB
>
[quoted text clipped - 9 lines]
>
> any solutions out there???
Wolffang - 30 Oct 2004 17:59 GMT
Thank you for your answer...

This is what i have so far.... but i am geting an error.... where the OrderID is not being passed from the datagrid "dgOrders" to the stored procedure... but the checkbox is working... is this because i am using FindControl???

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim dg As DataGridItem

Dim ck As CheckBox

Dim OrdID As Label

Me.SqlConnection1.Open()

For Each dg In dgOrders.Items

ck = dg.FindControl("chkSelect")

OrdID = dg.FindControl("OrderID")

If ck.Checked = True Then

Me.SqlCommand1.Parameters("@OrderID").Value = OrdID

Me.SqlCommand1.Parameters("@AdminUserName").Value = lblUserName.Text

Me.SqlCommand1.Parameters("@AdminProcess").Value = 1

Me.SqlCommand1.ExecuteNonQuery()

End If

Next

Me.SqlConnection1.Close()

End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.