473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to selected rows on gridview?

Hi, I'm having problem with my rows on gridview. When i click on the approve button, only the first row of the grid will update. Does anyone know how to make it that when i click on the different button on different row different rows will update. My code is as below...

Sub CustomersGridView_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)

' If multiple buttons are used in a GridView control, use the
' CommandName property to determine which button was clicked.

Dim str As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("database\db1.mdb")

If e.CommandName = "Approve" Then
'Str = "Update Table3 Set Status='6' Where Status =''"
'myCommand = New OleDbCommand(Str, con)
'myCommand.ExecuteNonQuery()
'Label1.Text = ("Successfully Approve")
'con.Close()

'Dim index As Integer
Dim mySelectQuery As String = "SELECT State, FileID FROM Table3"
Dim row As GridViewRow = GridView1.SelectedRow
Dim myUpdateQuery As String = "Update Table3 Set State='6' where FileID=" & "'" & row.Cells(1).Text & "'" & ""

Dim myConnection As New OleDbConnection(Str)

Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)

Dim myCommand2 As New OleDbCommand(myUpdateQuery, myConnection)

Dim retvalue As Integer

myConnection.Open()

myCommand2.ExecuteNonQuery()

Console.WriteLine(retvalue)

Dim myReader As OleDbDataReader

myReader = myCommand.ExecuteReader()

'Always call Read before accessing data.

While myReader.Read()
Label1.Text = ("Successfully Approve")

End While

'always call Close when done reading.

myReader.Close()

'Close the connection when done with it.

myConnection.Close()
End If
Apr 16 '07 #1
2 1562
Hi
Is it like this that there are approve buttons on every row on the gridview and that if you click on any button on any of the rows only the first row will be updated?
Please make it clear.

Regards
TeenzoneZ
Apr 16 '07 #2
Hi
Is it like this that there are approve buttons on every row on the gridview and that if you click on any button on any of the rows only the first row will be updated?
Please make it clear.

Regards
TeenzoneZ
Yes, there is a approve button on every row and if you click on the first button, the first row will update, click on the second button and the second row will update etc.
Apr 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Neil | last post by:
I have a gridview which is being populated with no problems. I want to be able to reference the data from the cells in the row but having followed an example on MSDN cannot get any data to be...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
3
by: Karl Rhodes | last post by:
I have a datagridview which is populated via a datatable. What I would like to dynamically set a selected row and have that row show up in the datagridview and not have to manually scroll to find...
1
by: jobs | last post by:
Given the Gridview below: When I select the button "Rate" and fall into this code. How can I reference "carriercode" and others . Apparently selecting the button does not select the row. I've...
0
by: Child X | last post by:
Hi all, I have a web form with two GridViews on it. GridView 'A' populates GridView 'B' based on it 'SelectedRowValue'. What i am after, is ...if someone delete a row from grid 'A' and it is...
1
by: Steve Kershaw | last post by:
Hi, I have a GridView in which I have selected a row. I now want to use the 1st column value of that selected row in another GridView as an input to select the particular row in the second...
2
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent...
3
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview with one of the columns as a template column with a button. When the user selects the button is there a way to get the row number in the button_Click event? Another one of...
1
by: imbirek8 | last post by:
Hi, I use GridView control in asp.net. I would like to write an event on the client site. When somebody click on row, I would like to clear all selected rows in GridView and changed cliked row...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.